khess Posted February 3, 2013 Share Posted February 3, 2013 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. Link to comment https://forums.phpfreaks.com/topic/273994-another-php-with-powershell-problem-piping/ Share on other sites More sharing options...
requinix Posted February 4, 2013 Share Posted February 4, 2013 $_ is a valid variable name... Link to comment https://forums.phpfreaks.com/topic/273994-another-php-with-powershell-problem-piping/#findComment-1409965 Share on other sites More sharing options...
Kingy Posted February 4, 2013 Share Posted February 4, 2013 try and escape the $ sign to stop it being used as a variable. Link to comment https://forums.phpfreaks.com/topic/273994-another-php-with-powershell-problem-piping/#findComment-1409967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.