I'm attempting to query an Exchange server using a powershell script executed by PHP and it doesn't seem to be working. The command I'm attempting to run is:
powershell "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010";"Get-CASMailbox -Identity [email protected] | fl ActiveSyncEnabled"
If I type that directly into the command prompt, it executes correctly and returns:
ActiveSyncEnabled : True
When I try it in PHP:
$output=shell_exec('powershell "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010";"Get-CASMailbox -Identity [email protected] | fl ActiveSyncEnabled"');
I get nothing. $output is set but blank. If I add "> output.txt" to the end, I get a blank text file. I'm able to run other, simpler powershell commands successfully via PHP, but not this one. The Apache service is running as the same user as when I successfully executed the script via the command prompt.
Any ideas?
I'm running:
- Windows Server 2008 R2 SP1 64-bit
- Apache 2.2.22 32-bit
- PHP 5.2.17 VC6 32-bit
- Exchange Management Console 2010