Jump to content

khess

Members
  • Posts

    4
  • Joined

  • Last visited

khess's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here's another interesting problem with running a powershell command inside system(): This command works at the PS command line: PS> Get-wmiobject win32_service | Where-object { $_.StartMode -eq "Auto" } But this command in a php script doesn't work: system("powershell -command Get-wmiobject win32_service | Where-object { $_.StartMode -eq "Auto" }"); Even this doesn't work: system("powershell -command Get-wmiobject win32_service | Where-object { $_.StartMode -eq \\\"Auto\\\" }"); I think it has to do with piping a command into another command. But it could be something else. I still can't get the command that PHP sees to print out to screen so that I can see what's being parsed. I think if I could see that, then I might not have to ask.
  2. Perfect!!! the three \'s made it work! Thank you very much.
  3. Yes, this is PowerShell 3.0. The PowerShell command works, as does yours at the PS command line but yours doesn't work in my php script. Is there a way that I can get the command to print out to screen to see how it's being parsed? This hasn't worked: $query = system (" command stuff"); echo $query;
  4. I am trying to solve the following problem in a php script. This works: system("powershell -command get-wmiobject win32_service -computername SERVER1"); It returns the expected results. However, this returns nothing: system("powershell -command get-wmiobject win32_service -computername SERVER1 -filter "startmode='auto'""); I've tried escaping the single and double quotes in almost every possible combination. For example: ...SERVER1 -filter \"startmode=\'auto\'\" and ...SERVER1 -filter \"startmode='auto'\" And nothing seems to work past the SERVER1. Anyone have any ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.