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:
<?php
$output = shell_exec('powershell.exe "(get-service Webclient -computername server1).Status"');
echo "Webclient: $output ";
?>
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.
This works (locally):
<?php
$output = shell_exec('powershell.exe "(get-service Webclient).Status"');
echo "Webclient: $output ";
?>
I've tried to change shell_exec to exec or system, but with no effect. Thank you.