SharePoint 2016: How to configure Usage & Health Service Application using PowerShell

Usage & Health Service Application is one of the most important Service Applications that provides vital information on the Health & State of SharePoint Farm.

In SharePoint 2016, Usage Service is collecting information on Timer Service Monitoring, Event Logs, Performance Counters, Search Usage, Sandbox Usage, and Site Collection Usage and much more.

This Service application is responsible to keep monitoring the resource, health & state associated with the SharePoint Farm and logs this information to Log Files on SharePoint Hive or any designated path along with SharePoint Logging Database “WSS_Logging” in SQL Server Database.

Many other components in SharePoint like Developer Dashboard, Search Analytics, Web Analytics Reports are using this data to provide logical User Interface for the end users.

You will get empty reports in Web Analytics reports section, if usage and health data collection service application is not configured properly.

It is not possible to Provision Usage & Health Service using Central Admin, as there is no User Interface available.

Let us first get into Central Admin Site to see if there is options available on the User Interface to provision Usage Service

Go to “Central Admin” – > “Manage Service Applications”

2

Click on “New” Menu on the Ribbon and in the existing list of available Service Application Templates we can see there is no template available for provisioning “Usage & Health Service Application”

3

This concludes that we have to provision Usage Service using PowerShell as shown in the following steps-

1

Launch “SharePoint 2016 Management Shell”

4

Step 1: Provision Service Application Instance

In this step, we will provision the Usage Service using “New- SPUsageApplication” cmdlet as shown below

New-SPUsageApplication -Name "Usage and Health Data Collection"

5

Step 2: Provision Service Application Proxy

In this step, we will provision Service Application Proxy for Usage Service by using the following commands

$serviceProxy = Get-SPServiceApplicationProxy | where {$_.TypeName -eq "Usage and Health Data Collection Proxy"}

6

$serviceProxy.Provision()

7

Step 3: Verify Service Application

In this step we will verify the provisioning of service application by looking at “Service Application” Page in “Central Administration” as shown below-

8

Step 4: Verify Service Application Database

In this step we will verify the provisioning of service application database by logging into “SQL Server Management Studio” as shown below-

9

10

This concludes the Service Application Provisioning Process using PowerShell.

Hope you find it helpful.

Advertisements

SharePoint 2016: How to configure Search Service Application using PowerShell

In this article we will discuss how to provision Search Service Application for SharePoint 2016 using PowerShell

During this whole article I will guide you steps involved in provisioning Search Application along with the corresponding PowerShell Script

Here the steps that we will explore in the upcoming section-

1

2

3

Though we can provision Search Application from Central Admin as well but the purpose here is to demonstrate the use of PowerShell commands required to provision Search Application so that’s what we will do.

First let’s go to Central Admin to ensure that there is no existing instance of Search Service Application has been provisioned earlier

Under Application Management -> Click on “Manage Service Applications”

4

Here we can see what all Service Application Instances provisioned earlier and we can see there are none

5

Now launch SharePoint Management Shell to run the required PowerShell commands

6

We will run the PowerShell commands in the following order to make sure each Sub component provisioned as desired.

Step 1: Provision Service Application Instance

In this Step we will first provision Search Service Application using the following cmdlet-

$sa = New-SPEnterpriseSearchServiceApplication -Name "Search Service Application" -DatabaseName "SearchDB" –ApplicationPool  "SecurityTokenServiceApplicationPool"

Make sure Application Pool should exists before you run this command else it will fail since this cmdlet wont’ add the Application Pool automatically

7

Step 2: Provision Application Proxy

Then we need to provision Application Proxy by using following cmdlet referring the Service Application Instance provisioned in the previous step

New-SPEnterpriseSearchServiceApplicationProxy -Name "Search Service Application Proxy" -SearchApplication $sa

8

Step 3: Validate Service Instance

Next step is to validate that the Service Instance is online and to do so we can use the following cmdlet

Get-SPEnterpriseSearchServiceInstance -local

9

Step 4: Clone Topology

Next step is to clone the topology which is required in order to make any changes to the search topology in a search installation that has items in the search index

As per Microsoft recommendation around this you need to modify this new topology object, which is a clone of the active topology, by adding or removing search components. After you have made the changes to the clone topology object, you have to activate this clone to have this topology in action.

$clone = $sa.ActiveTopology.Clone()

10

Step 5: Get Search Service Instance Server Name

This Server name is required in the upcoming steps to it is wise to make use of the following cmdlet to retrieve the server name

Get-SPEnterpriseSearchServiceInstance| Select Server

11

Step 6: Get Search Service Instance

Then we get handle over the search service instance running on the respective server using the following cmdlet

$si = Get-SPEnterpriseSearchServiceInstance | ?{$_.Server -match "SP-2016-Dev"}

This reference object will be used in the upcoming steps

12

Step 7: Provision Admin Component

Next step is to provision a new Admin Component for the given topology and search service instance using the following cmdlet. This cmdlet is using reference to search service instance we get in the earlier steps

New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $si

13

Step 8: Provision Processing Component

Next step is to provision new content processing component for the given topology and search service instance using the following cmdlet

New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $si

14

Step 9: Provision Analytics Component

Then we have to provision new analytics processing component for the given topology and search service instance using the following cmdlet

New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $si

15

Step 10: Provision Crawl Component

Then we have to provision new crawl component for the given topology and search service instance using the following cmdlet

New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $si

16

Step 11: Provision Index Component

Then we have to provision new index component for the given topology and search service instance using the following cmdlet

New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $si -IndexPartition 0 -RootDirectory C:\SearchIndex\

RootDirectory: Specifies the root directory that will hold the index location for the new search index component. If you plan to isolate the index on dedicated discs in order to avoid I/O contention that may leads to performance degradation as it might be a risk that index filling up the OS disk and ruin the overall server performance.

17

Step 12: Provision Query Component

And finally we have to provision new query processing component for the given topology and search service instance using the following cmdlet

New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $si

18

Step 13: Activate New Topology

Once all the components has been added to the new topology, activate it by using following cmdlet

$clone.Activate()

19

Step 14: Clean Inactive Topologies

Finally we have to clean all the inactive topologies associated with a search service application. We can perform this clean by using the following the code using “Remove-SPEnterpriseSearchTopology” cmdlet

foreach($tp in (Get-SPEnterpriseSearchTopology -SearchApplication $sa | ?{$_.State -eq "Inactive"}))
{    
   Remove-SPEnterpriseSearchTopology -Identity $tp -Confirm:$false
}

20

Step 15: Change Default Content Access Account

And we can change the default content access account by using the following code

$sa = Get-SPEnterpriseSearchServiceApplication

$content = New-Object Microsoft.Office.Server.Search.Administration.Content($sa)

$content.SetDefaultGatheringAccount("<Enter User Name>", (ConvertTo-SecureString "<Enter Password>" -AsPlainText -Force))

21

Now it is time to validate if search service application has been provisioned correctly.

Go to Central Admin -> Manage Service Applications

We can see a new Search Application has been provisioned successfully by clicking the Search Service Application Link

22

And we can see all the component are provisioned and running as expected.

23

Also we can validate the SQL Databases that has been provisioned during creating new search service applications as shown in the following screenshots

242526

Hope you find it helpful.