If we need to do something with service application instances, we normally use the PowerShell “Get-SPServiceInstance” command. For a certain task I needed to do some modifications to “Search Host Controller Service”. So I executed following command.
1: $sh = Get-SPServiceInstance | ? {$_.TypeName -eq "Search Host Controller Service"}
1: $sh.id
But surprisingly I got 2 ids.Does that mean that I have 2 active Search Host Controller Service service instances running?. and what is the relevant Guid for my next commands?
To clarify doubts let’s think how service applications/service application instances are kept in SharePoint. When we install SharePoint in a server new service application instances are created. But they may not be in active state. We can easily see that from the services on this server section in central administration.
But how can I get other information like their guids. We can use PowerShell to easily get that info. We can start with a script like below.
1: Get-SPServiceInstance | Sort TypeName | Format-Table TypeName,Id,Server
You can see following resultsAs you can see I have 2 copies of each service application instances. That is because I have 2 SharePoint servers in my farm. So how can I know which service application instance(s) are running at the moment. We need to modify our script a little bit.
1: Get-SPServiceInstance | Sort TypeName | Format-Table TypeName,Id,Status,Server
Now we can see service instances with their status as belowAs you can see not all service application instances are in Online state. In our next modification to the script we will filter all Online services
1: Get-SPServiceInstance | where {$_.Status -eq "online" } | Sort TypeName | Format-Table TypeName,Id,Status,Server
The result will be as belowAs I needed the guid of online “Search Host Controller Service” instance I can easily get from above or I can modify the where clause to input the TypeName to return only the specific service application instance.
No comments:
Post a Comment