Sonntag, 9. Juni 2013

PowerShell for SharePoint 2013 Analytics Feature

First of all
Thanks a lot to Thomas Molbach from Microsoft. He sends me his Scripts from his Session SPC 202 from last year SharePoint Conference in Las Vegas. So most of the PowerShell commands in this article are based on his scripts.
Working with PowerShell and the new SharePoint Analytics feature means that you have to set up your PowerShell environment first. Using the SharePoint Management Shell as it is won’t work.
Common stuff
To setup up a Management Shell you need to run the following script:

#Set up the Anaytics powershell environment
Add-PSSnapin Microsoft.SharePoint.PowerShell
Add-PSSnapin hostcontrollerpssnapin
Add-pssnapin junopssnapin
Add-pssnapin searchcorepssnapin
Add-pssnapin enginepssnapin
Add-pssnapin analysisenginepssnapin
$env:CERES_REGISTRY_PRODUCT_NAME = "Office Server\15.0\Search\Ceres"
Connect-System -Uri (Get-SPEnterpriseSearchServiceApplication).SystemManagerLocations[0] -ServiceIdentity (Get-SPEnterpriseSearchService).ProcessIdentity
Connect-AnalysisEngine -NodeName AdminComponent1

The major part is: Add-pssnapin analysisenginepssnapin . As you see the Analytics feature is not part of the common SharePoint PowerShell Snapin.
If everything worked fine you get the following status back:

Connected to agent 'AnalysisEngineComponent' of type Microsoft.Ceres.AnalysisEngine.Shared.IAnalysisEngineAgent running

Now we are able to get a full list of available command using:
Get-Command -Module analysisenginepssnapin
Some useful scripts
 
Start Usage Analytics Job:
Start-Analysis UsageAnalytics
 
Start Search Reports Job:
Start-Analysis SearchReports
 
Start Search Analytics Job:
$tj= Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition
$sa = $tj.GetAnalysis("Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob")
$sa.StartAnalysis()
 
Display Search Analytics Job status info:
$a = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition
$sa = $a.GetAnalysis("Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob")
$sa.GetAnalysisInfo()
Display all Analytics Job status info:
Get-Analysis

1 Kommentar:

  1. Hi Nicki,


    Nice and useful article, Thanks for sharing,looking forward for more posts like this.







    Sharepoint Developers

    AntwortenLöschen