PowerShell Script to list services running on all servers in a farm
I have written the following script to list the services running on each server in a SharePoint farm and their status, utilising the Get-SPServer cmdlet.
<# -------------------------------------------- SharePoint 2010 PowerShell script to list the services running on each server in a farm. File : ListServices.PS1 Author : David Webb Date : 19/10/2013 Version : 1.0 Revision history: ----------------- 1.0 Initial version --------------------------------------------- #> # ------------- # Set variables # ------------- $Servers = Get-SPServer # ------------ # Begin script # ------------ ForEach ($Server in $Servers) { Write-Host "Services running on" $Server.Name "..." $Table = New-Object System.Data.DataTable "$Server.Name" $Column1 = New-Object System.Data.DataColumn "Service",([String]) $Column2 = New-Object System.Data.DataColumn "Status",([String]) $Table.Columns.Add($Column1) $Table.Columns.Add($Column2) $Services = $Server.ServiceInstances ForEach ($Service in $Services) { $Row = $Table.NewRow() $Row.Service = $Service.TypeName $Row.Status = $Service.Status $Table.Rows.Add($Row) } $Table | Format-Table –AutoSize }
And here is a screenshot of the script in action:
Feel free to copy the code and use the script as you see fit (at your own risk of course, I can not and will not take responsibility for any undesired outcome).