How to remotely restart Windows service with Powershell
In case if you need to remotely restart Windows service, here is my Powershell script.
As soon as we have ICMP/ping disabled between our development environments, I've used WMI pings to determine, if remote machine is running.
$pc = Get-ADComputer -filter * $pc | %{ $ping = $(Get-WmiObject -Class Win32_PingStatus -Filter "Address='$($_.name)' AND Timeout=1000").statuscode; if ( $ping -eq 0 ) { $service = Get-Service -Name "WindowsAzureGuestAgent" -ComputerName $_.Name Restart-Service -InputObject $service -Verbose } }
script (en), Windows (EN), powershell (en)
- Hits: 8238