SharePoint 2013 LogAnalyticsApp – PowerShell script to register the Event

Sathish Nadarajan
SharePoint MVP
Published On :   29 Jul 2013
Visit Count
Today :  1    Total :   8069

In one of my previous post I have explained about SharePoint 2013 LogAnalytics app event.  Now let us see, how we can register the event with a corresponding GUID, which will be used for Log Analytics.

The script is self-explanatory and for any clarifications, please post your comments.

 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 # To get a site at the root site collection level:
  $Site = Get-SPSite "https://c4968397007.dc07.loc:9470/sites/ADFSTest"
 # To create a custom usage event type:
 $SSP = Get-SPEnterpriseSearchServiceApplicationProxy
 # Creating a new GUID
 $EventGuid = [Guid]::NewGuid();
 # Name of the EVENT
 $EventName = "Item Checkout from ProductCatalog ADFSTest";
 $tenantConfig = $SSP.GetAnalyticsTenantConfiguration([Guid]::Empty);#
 $newEventType = $tenantConfig.RegisterEventType($EventGuid, $EventName, "ADFSTest-31May2013")
 # Writing the GUID.  This should be noted down.
 Write-Host $EventGuid 

To verify and the get the list of events registered, execute the below command.

 #To verify the Registered Events.
  Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 $SSP = Get-SPEnterpriseSearchServiceApplicationProxy
 $SSP.GetAnalyticsEventTypeDefinitions([Guid]::Empty, 3) | ft