Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Constructive Script Criticism

$
0
0
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.

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."}}
Many thanks.




Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>