I am using the following Powershell script in hopes of identifying Started service applications by server.

Spot checking the results shows something unexpected. For instance, I know Lotus Notes Connector is Stopped on all servers in my farm but the script returns it.

What other additional properties must I test for to be sure I am seeing the exact same results as shown in Central Admin "Manage Services on Servers" page?

[System.Collections.ArrayList]$ReportInfo = New-Object System.Collections.ArrayList($null)

$servers = (get-spfarm).servers
foreach ($server in $servers)

    foreach($service in $server.serviceinstances)
        if($service.TypeName -eq "Lotus Notes Connector"){
            Write-Host stop;

        if ($service.status = "Online")
            Write-Host "Server" $server.Name "`tService: " $service.TypeName;

            $servicInfo = @{}
            $servicInfo.Server = $service.Server.Name;
            $servicInfo.Service = $service.TypeName;

            $ReportInfo.Add((New-Object PSObject -Property $servicInfo))>$null;

Write-Host "Exporting CSV"

$ReportInfo | Export-Csv  "Services.csv" -NoTypeInformation -Encoding UTF8 -Delimiter '|'
  • Pls change <br/> if ($service.status = "Online") <br/> by <br/> if ($service.status -eq "Online") <br/> – user46987 Sep 15 '15 at 8:08

What is wrong with simply using

Get-SPServiceInstance | select typename, status, server | Export-Csv test.csv

to get the data?

  • Nothing. Looks great. Thanks for simplifying for us. – ChiliYago Nov 5 '13 at 19:29

When using PowerShell to get the service instances, they all seem to come back online, as you describe. However, if we do it in a C# method, it comes back correctly. Here is what I did to make them come back correctly:

$Assem = ( 
    "Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" 

$Source = @" 
using Microsoft.SharePoint.Administration; 
using Microsoft.SharePoint; 
using System.Collections.Generic;
using System; 

namespace ReportingStuff 
    public static class Servers  
        public static List<SPServiceInstance> GetInstances() 
            List<SPServiceInstance> items = new List<SPServiceInstance>();

            foreach (SPServer server in SPFarm.Local.Servers)
                foreach (SPServiceInstance instance in server.ServiceInstances)
                    if ((!instance.SystemService && !(instance.GetType().FullName.Contains("SPAdministrationServiceInstance"))) && (!(instance is SPTimerServiceInstance) && (server.ServiceInstances.GetValue<SPTimerServiceInstance>() != null)))

            return items;

Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp  

$output = [ReportingStuff.Servers]::GetInstances()
Write-Output $output

You can use the method to get your collection of instances and then do your filtering, outputting, etc.

  • That is some crazy powershell code. Never seen that before. Thanks I'll try it. – ChiliYago Oct 31 '13 at 18:18
  • This is not coming back correctly either. Lotus Notes Connector Online c6a52514-1689-4d38-a235-62b96e9e577a – ChiliYago Oct 31 '13 at 20:12
  • Do all of the services show online with that script? – John Chapman Oct 31 '13 at 20:53
  • I ran it again and and all Lotus Notes Connectors are listed as Disabled. Cant explain why previous cut/paste showed Online but I am going to mark this a solved for now. Thanks Lotus Notes Connector Disabled c6a52514-1689-4d38-a235-62b96e9e577a Lotus Notes Connector Disabled 2b35170b-f238-4bbd-a67c-96576f2ad4b1 Lotus Notes Connector Disabled c5565fab-8eee-4c02-a666-361175268cca Lotus Notes Connector Disabled b587822e-9ece-444b-86c0-99beb6606f57 Lotus Notes Connector Disabled ad73f115-30ec-49b3-8bd0-43071c3da4e1 – ChiliYago Oct 31 '13 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.