Ok, I'm stuck. I am trying to check if a service is running on a remote machine, and my script is able to tell if the service is running on the remote machine or if it is stopped. But it cannot start the service. Below is my code:
Powershell
#--- VARIABLES ---##region variables$ServiceName='Service Name'$name="WORKSTATION1"#end region variables#--- SCRIPT ---##region script$arrService=Get-Service-ComputerName$name-Name$ServiceNamewhile($arrService.Status-ne'Running'){Start-Service$ServiceNamewrite-host$arrService.statuswrite-host'Service starting'Start-Sleep-seconds30$arrService.Refresh()if($arrService.Status-eq'Running'){scriptres:"Ok,Running"}}
But PS just loops and loops, and the service on the remote machine does not even attempt to restart. I can restart the service on the remote machine...