PowerShell Basics: Listing the number of services each user has per server


Infrastructure audits can be fun right? While they can be tedious at best, most IT Professionals are prepared via the use of Operations Management Suite or other 3rd party software that can literally produce a report in minutes (depending on infrastructure size of course!)

What about if you don’t have access to these tools?

Fear not as there are many PowerShell scripts that can reliably provide the required information needed. However, some assembly of the required report may be required.

One common ask most IT Professionals receive when audited is to provide a listing of services used by each user has per server. This inquiry is common when an audit is required to prove users have been assigned appropriate services per server.  Simply utilize the following PowerShell script to automate this function and skip the manual route:

$server_names = Get-Content "C:\Servers_list.txt"
Foreach ($server in $server_names){
Get-WmiObject Win32_service | Where-Object {$_.state -eq "Running"} | Group-Object -Property StartName | Format-Table $server,Name, Count -auto >> c:\ServiceAccounts.txt
}

PowerShell_Tips_Tricks_thumb.png

Comments (0)

Skip to main content