List SharePoint Services on Server using PowerShell

Manage Services on Server shows which SharePoint service is running on a particular server. You can only select 1 server and you won’t get a quick overview of all the services per server. I have created the below script to create a .html file which shows each server and their active or inactive service.

The following script can be copied into notepad and saved as a .ps1 file. Just execute the script to create a .HTML file. When you run the script, it will ask for an export location. This folder does not have to exist on your harddrive. This has been created and tested for SharePoint 2013 and haven’t tested this yet for SharePoint 2010.

#Import SharePoint PowerShell Modules
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Request the location to store the HTML file
$ExportLocation = Read-Host "Enter the location to store the HTML file. (eg. C:\temp). This directory will be created if it doesn't exist"

Function ListServicesOnServer($path)
{
#Check if directory exists or create the directory
if((Test-Path $path) -eq $false)
{
mkdir $path
write-host "Folder created" -foregroundcolor yellow
}
else
{
write-host "Folder already exists" -foregroundcolor yellow
}

#create an unique name
$date = get-date
$today = $date.ToString("ddMMyyyy_HHmm")
$HTMLpath = "$($path)\ServicesOnServer_$($today).html"

#Create HTML File for the information
New-Item -ItemType file $HTMLpath -force | out-null
add-content -value "<html><body><h1>Services on Server</h1><br />" -path $HTMLpath

#Try / Catch statement to get the information
try
{
#Get the SharePoint servers in the farm
$servers = Get-SPServer | where {$_.Role -ne "Invalid"}

#Create an HTML Table and headers
add-content -value "<table border='1' style='font-family: Calibri, sans-serif'>
<tr>
<th style='background-color:blue; color:white'>Service</th>" -path $HTMLpath
$servers | %{Add-Content $HTMLpath "<th style='background-color:blue; color:white'>$($_.Address)</th>"}
add-content -value "</tr><tr>" -path $HTMLpath

#list all services using 1 server
$services = get-spserviceinstance -server $servers[0]

foreach($service in $services)
{
$serviceTypeName = $service.TypeName | sort-object
Add-Content $HTMLpath "<td>$($service.TypeName)</td>"
$servicesOnServers = get-spserviceinstance | where-object {$_.TypeName -eq $serviceTypeName} | %{Add-Content $HTMLpath "<td>$($_.status)</td>"}
Add-Content $HTMLpath "<tr></tr>"
}

add-content -value "</table></body></html>" -path $HTMLpath
write-host "Script Done" -foregroundcolor green
}
catch
{
write-host "$($_.Exception.Message)" -foregroundcolor red
}
}

ListServicesOnServer($ExportLocation)

Manual

You should already have created a .ps1 file and saved this to a predefined location:

ListServicesOnServer1

Run PowerShell as administrator and run the following command:

& “C:\Temp\ListServicesOnServer.ps1”

ListServicesOnServer2

Press enter and fill in a location:

ListServicesOnServer3

Press enter:

ListServicesOnServer4

The output should look like below:

ListServicesOnServer5

SharePoint: Unable to retrieve topology component health states

We encountered the below error during a fresh SharePoint 2013 installation using AutoSPInstaller.

image

‘Unable to retrieve topology component health states. This may be because the admin component is not up and running.’

I have seen a few blogs that mentions this error but most of them provided a solution which isn’t really helpful like an complete reinstall of the SharePoint farm. I have also seen a few who say to delete the Search Service Application (SSA), restart the servers and recreate the SSA; this could solve the issue for some but unfortunately this was not the case for my SharePoint 2013 farm.

Solution

In my scenario we resolved this issue by provisioning the WSS Usage Application Proxy using the following PowerShell commands:

$UP = Get-SPServiceApplicationProxy | where {$_.TypeName -like "Usage*"}
$UP.Provision()

Other possible solutions we used during other installations

1. Removing the extra space at the end of ‘PSModulePath’

Go to the System Properties

image

Environment Variables…

image

Edit PSModulePath

image

And remove the space. Restart HostControllerService after this change.

2. Set the service accounts again in Central Administration

It is also possible the Service Account did not fully provision itself during configuration of the Search Service Application.

Go to the Security tab in Central Administration

image

Configure Service accounts

image

Verify if the correct service account is present and just click on OK. Start an IISReset and verify if the states are visible again.