Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Powershell Services Script
#1
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.
Reply
#2
oooo very nice. I love powershell myself. I use it all the time at work. Very useful. I'll give this script a go
"Death smiles at us all. All a man can do is smile back".
[Image: siggy.png]
MSN: Xzotic@live.com
Reply
#3
Here's an example of what it looks like in action:

*The list was too big, so I can't fit it into one screenshot, but it will list out Running services, numbered starting from 1). Then it will list Stopped services starting from 1). What you see in the script here is the last of the list in the Stopped services, and the information that it displays at the very end as a sort of "Statistic."

[Image: ibTPGnzjA.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [GUI PowerShell] Get_UserACC - Get All User Accounts Info from WMI (Advanced Script) AceInfinity 4 2,144 01-06-2012, 05:22 PM
Last Post: AceInfinity
  Get Top 5 CPU Consuming Processes {PowerShell} AceInfinity 10 7,016 08-21-2011, 08:22 AM
Last Post: AceInfinity
  PowerShell Hotfix List Script - Created by Ace AceInfinity 4 1,945 08-16-2011, 12:09 PM
Last Post: AceInfinity

Forum Jump:


Users browsing this thread: 1 Guest(s)