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.![image image](http://lh5.ggpht.com/-zVRIhiZ9-68/UkE4eUfqgLI/AAAAAAAAAeA/MxZf45PLuZk/image_thumb%25255B5%25255D.png?imgmax=800)
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.
![image image](http://lh3.ggpht.com/-21AgUhKR3g8/UkE4g5Z2r0I/AAAAAAAAAeQ/UznZF5YWZHY/image_thumb%25255B21%25255D.png?imgmax=800)
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 results![image image](http://lh6.ggpht.com/-N32qzbfmbyg/UkE4jhA2M5I/AAAAAAAAAeg/MK1m1louK30/image_thumb%25255B10%25255D.png?imgmax=800)
As 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 below![image image](http://lh5.ggpht.com/--03hXRQ0K2Y/UkE4mewuQuI/AAAAAAAAAew/6TR3biTudgE/image_thumb%25255B15%25255D.png?imgmax=800)
As 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 below![image image](http://lh5.ggpht.com/-ffnG63PY5Xk/UkE4pJgXcgI/AAAAAAAAAfA/M4c7SNg1JGo/image_thumb%25255B18%25255D.png?imgmax=800)
As 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