Archive for June, 2013

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 »