Link to home
Start Free TrialLog in
Avatar of wicked212
wicked212

asked on

Service Stop Validation

Hi,
I am attempting to stop a remote service (which works great) but struggling to validate that the service has been stopped. Basically, if determined/verified to be stopped, would like to continue the script. If not stopped, then it is likely hung, and I would like to abort and LogWrite that the service was not stopped. Please advise.

$Servers = Get-content "C:\path\servers.txt
foreach ($Server in $Servers)
{
LogWrite "Issuing remote service stop command to $Server"
#Command to stop service
(Get-WmiObject Win32_Service -computername $Server -Filter "Name='Service_Name'").StopService()
LogWrite "Service stopped on $Server"
}
ASKER CERTIFIED SOLUTION
Avatar of mouseware
mouseware

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wicked212
wicked212

ASKER

ty mouseware!