08-16-2011, 10:01 PM
(This post was last modified: 08-17-2011, 10:50 PM by AceInfinity.)
Code:
$Services_ = Get-Service | write-output
$running = 1
$stopped = 1
write-host
write-host "#" Running Services "#" -foregroundcolor "magenta"
foreach ($objItm in $Services_) {
$Display_ = $objItm.DisplayName
If ($objItm.Status -eq "Running") {
write-host " "$running")" $objItm.Name "("$Display_")" -foregroundcolor "gray"
$running += 1
}
}
$running -= 1
write-host
write-host "#" Stopped Services "#" -foregroundcolor "magenta"
foreach ($objItm in $Services_) {
$Display_ = $objItm.DisplayName
If ($objItm.Status -eq "Stopped") {
write-host " "$stopped")" $objItm.Name "-- ("$Display_")" -foregroundcolor "gray"
$stopped += 1
}
}
$stopped -= 1
write-host "-------------------------------------------------------------------" -foregroundcolor "magenta"
write-host "#" There are a Total of $running Running Services, and $stopped Stoppped Services -foregroundcolor "magenta"
write-host "-------------------------------------------------------------------" -foregroundcolor "magenta"
write-host
Here's my newest powershell script, a little more advanced, using logic functions like the if statement to sort out Running and Stopped processes with an integer count for each process and details after both object items have been listed.