Posts Tagged ‘SharePoint 2013’

Radu Tut did a wonderful blog about how to get Search Analytics Reports programmatically in SharePoint 2013. I am quite grateful for his guidance and it’s undoubtedly the most referenced article on the topic (even being referenced in Microsoft blogs and other documentation).

I followed Radu’s guidance and have successfully retrieved usage data from my site collections in 2013, but I’ve discovered a few things I’ve not seen anyone talking about:

  1. It is important to note that the DateTime value you use should be UTC. If not, you will, at some time during the day–depending on your offset–get a “Specified argument was out of the range of valid values” error when trying to get the furthest back data (example: -14 days for Day) if you use Local time. Internally, SharePoint uses DateTime.UtcNow.Date (see reflection of Microsoft.Office.Server.Search.Analytics.AnalyticsItemData in the Microsoft.Office.Server.Search.Applications.dll).
  2. To my surprise, I was able to retrieve usage data from a 2010 site collection in SP2013! Apparently, SharePoint is tracking and compiling this data, but the 2010 UI has no way to interface with the data. Thus, if you need usage data for a 2010 UI site collection in SharePoint 2013, turn to your Devs or PowerShell-savvy Admins: If your site is being crawled, the 2013 usage data you seek is in there!
  3. The time period for SP2013 to compile usage data is fairly lengthy (at least 15 minutes in my tiny dev farm). If you attempt to retrieve the data while SharePoint is compiling it, you’ll get back a big fat ‘0’. For expected results, make sure you’re not retrieving the data while SharePoint is compiling it. 🙂 I believe this compilation is done by a timer job once a day at midnight, by default (I was up pretty late working on my project when I discovered this behavior).

Happy reporting!


Read Full Post »

Okay, so apparently there is a difference between SharePoint PowerShell and Windows PowerShell ISE. I was attempting to write a script based off of Deploy by using DBA-created database (SharePoint Server 2010) (yah, 2010 guidance for 2013–apparently the 2013 guidance isn’t yet available). Naturally, I didn’t want to just take the script at face value and run it without understanding it. So, I started walking through it one line at a time to see the results. What better tool to use when writing and debugging PowerShell than the PowerShell ISE? (That’s a rhetorical question! I’m sure many of you have other tools vastly superior.) Naturally, you have to Add-PsSnapin Microsoft.SharePoint.PowerShell when using the ISE, but the line by line debugging is well worth it to me. Unexpectedly, when I got to the New-SPEnterpriseSearchServiceApplication line, I got an error: “Requested registry access is not allowed.”

PS C:\> $searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchAppName -ApplicationPool $appQueryPool -AdminApplicationPool $appAdminPool -DatabaseServer $databaseServer -DatabaseName $adminDB
New-SPEnterpriseSearchServiceApplication : Requested registry access is not allowed.
At line:1 char:14
+ $searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchAppName -Appl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Offic...viceApplication:NewSearchServiceApplication) [New-SPEnterpriseSearchServiceApplication], SecurityException
+ FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.NewSearchServiceApplication

Okay, that’s weird! After discovering how to use the Process Monitor to figure out what account was having troubles reading the registry, I still didn’t have any solution. Everything looked fine.

On a whim, I decided to try the lines of script in the SharePoint 2013 Management Shell… No problem.

So, moral of the story: If you’re having troubles with using cmdlets in Windows PowerShell ISE, try the SharePoint 2013 Management Shell. At least with New-SPEnterpriseSearchServiceApplication, there is a difference.

Update, 6/6/2013:
Sometimes there are gotchas, and this one got me. You need to be sure to run Windows PowerShell ISE as an Administrator just as you would SharePoint 2013 Management Shell. After some feedback from a SharePoint 2010 Master, I got to thinking I may have overlooked something. Appears I had! The New-SPEnterpriseSearchServiceApplication cmdlet did not give any error when I ran it from Windows PowerShell ISE as an Administrator. Unfortunately for me, the rest of the script provided in the 2010 guidance can’t be used, anyways, because several of the cmdlets don’t exist in 2013.

Read Full Post »