Good evening all,
Tragically this tiny script took me about an hour and a half to write, so I was looking for some tips to improve it and would appreciate any input.
Many thanks.
Tragically this tiny script took me about an hour and a half to write, so I was looking for some tips to improve it and would appreciate any input.
Powershell
#The host$hostname=$env:COMPUTERNAME#Services to check$services=@("tablet*","fax*")#Method to check services$servicecheck=Get-Service-Name$services|Select-ObjectName,Status|Where-Object{$_.status-eq"stopped"}#Outputvariables$servicestatus=$servicecheck.Status$servicename=$servicecheck.Name#Loop to write result of service statusforeach($servicenamein$servicename){if($servicestatus-eq"stopped"){Write-Host"The $servicename on $hostname has stopped."}}