$analytics = Get-SPUsageDefinition | where { $_.Name -like "Analytics*" } $pageRequests = Get-SPUsageDefinition | where { $_.Name -like "Page Requests" }
$analytics.Receivers.Count $pageRequests.Receivers.Count
if ($analytics.Receivers.Count -eq 0) { $analytics.Receivers.Add( "Microsoft.Office.Server.Search.Applications, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.Office.Server.Search.Analytics.Internal. AnalyticsCustomRequestUsageReceiver") } if ($analytics.EnableReceivers -eq $false) { $analytics.EnableReceivers = $true $analytics.Update() } if ($pageRequests.Receivers.Count -eq 0) { $pageRequests.Receivers.Add( "Microsoft.Office.Server.Search.Applications, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.Office.Server.Search.Analytics.Internal. ViewRequestUsageReceiver") } if ($pageRequests.EnableReceivers -eq $false) { $pageRequests.EnableReceivers = $true $pageRequests.Update() }