Get a service status on remote servers

With the following powershell script, you can get a service status on remote servers Script : $ErrorActionPreference = “SilentlyContinue” $strCategory = “computer” $objDomain = New-Object System.DirectoryServices.DirectoryEntry $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objDomain $objSearcher.Filter = (“(objectCategory=$strCategory)”) $colProplist = “name” ,

Restart a service on remote servers

This script restart the service name “SMS Agent Host” on the servers listed in the file C:\temp\BOOK1.txt Script : ForEach($MachineName In $hosts){ $service = Get-Service -ComputerName $MachineName -name “sms agent host” Write-Host $MachineName, $service.status, $ (new-Object System.ServiceProcess.ServiceController(‘sms agent host’,$MachineName)).Stop() (new-Object