I have simple powershell script which gets the offset of a Ubuntu server with the time of the NTP server.
The command I run is
$result = ssh -i C:\temp\privatekey domain\username@servername "ntpdate -q 192.168.10.1"
When I run this script manually the $result variable is populated as expected. When I run as a scheduled task (as the same user) the script does not set the $result variable at all leaving it blank.
Is there further options I need to enter as part of the SSH command or as part of the scheduled task calling the ps script? Any help very much appreciated.