Show all the Running Services

Checking the services on a machine is a easy job only if you want to check more than 1 machine.

The script below will help you on this.

$strComputer="."
$colItems=get-wmiobject -class "Win32_Service" -namespace "root\CIMV2" `
-computername $strComputer | sort "Caption" 

foreach ($objItem in $colItems) {
	if ($objItem.State -eq "Running") {
	write-host $objItem.Caption "("$objItem.Name")"  -foregroundcolor "green" }
	else {write-host $objItem.Caption "("$objItem.Name")" -foregroundcolor "red" }
}

to make it pretty i made the Running services in Green and else in Red

Published by iamfazul

Author of the site

Leave a comment