title: powershell - execute cmdlet remotely with php
body: <p>I need to get status of service for simple monitoring tool. There is no problem to get status locally, but when I try to get status of service on remote computer like this:</p>
  
  <pre><code>&lt;?php 
  $output = shell_exec('powershell.exe "(get-service Webclient -computername server1).Status"');
  echo "Webclient:  $output ";
  ?&gt;
  </code></pre>
  
  <p>I get nothing. WinRM on server1 is set to receive requests and to allow remote access. The Get-Service on remote server1 works fine in console window.</p>
  
  <p>This works (locally):</p>
  
  <pre><code>&lt;?php 
  $output = shell_exec('powershell.exe "(get-service Webclient).Status"');
  echo "Webclient:  $output ";
  ?&gt;
  </code></pre>
  
  <p>I've tried to change shell_exec to exec or system, but with no effect. Thank you.</p>