I was called in to a client to repair this error following a migration to SharePoint 2013. I talked to a few colleagues, and some actually have experienced with new SharePoint environments as well as migrated SharePoint environments. The approach that you use to build the environment also does not appear to be a relevant factor.
Most of the advice I got was to rebuild the environment. This certainly would work but also fixing the damn thing is an option as well.
The full error that you will receive is:
Add-PsSnapin : Cannot load Windows PowerShell Snap-In
Microsoft.SharePoint.PowerShell because of the following error: Unable to cast object of type ‘Microsoft.SharePoint.PowerShell.SPCmdletSnapIn’ to type
At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:3 char:1
+ Add-PsSnapin Microsoft.SharePoint.PowerShell
+ CategoryInfo : InvalidData: (Microsoft.SharePoint.PowerShell:St
ring) [Add-PSSnapin], PSSnapInException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
The CustomPSSnapIn Serves as a base class for snap-ins that are used to register a list of cmdlets and providers, this is standard PS shit nothing to fancy. The SPCmdletSnapIn is the destination cast type, this is the equivalent of the former, however specific with the relevant SharePoint additions.
Nothing to fancy going on here, and type cast exceptions outside of object reference errors are probably the most common error people run into. However fixing something like this when they are baked in types is a pain in the ass because you really don’t have access to the types, they are shipped with the product. The types themselves are the issue, and you don’t know whether its the SharePoint or Windows Management Framework types!
For me, it was the Windows Management Framework types that were causing this issue. To repair this error, simply do a an uninstall on Microsoft Windows Management Framework 3.0 (KB2506143) and reinstall using this http://www.microsoft.com/en-us/download/details.aspx?id=34595.
I was called into a client this morning whom had their SharePoint environment built by a separate SharePoint consultant (for shame!). When attempting to create a PowerPivot Service Application, they were encountering the following error:
System.IO.FileNotFoundException: Could not find file ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\Template\sql\PowerPivotDbSchema.sql’.
This error would not surface through the Web UI, however can be found in the SharePoint ULS logs. Seems easy enough to fix right? Looking under the path specified in the above however, you might not even see the parent Template directory!
Off the cuff, I assumed that PowerPivot simply was not installed. However this was not the case, rather the installation looked like it was right in specs.
Not going into the dull specifics off the error, the problem is with SQL Server 2012 SP1 (slipstreamed version) and PowerPivot. This error doesn’t appear to occur when you are not using the slipstream version. If it is on the menu, this repair could be used. However since this is a freakin cannon at a mosquito, here is a way to retrofit the environment and get around the error:
- Logon to the SharePoint machine. Repeat these steps for every box that participates in the SharePoint farm.
- If you haven’t installed PowerPivot, follow the steps outlined here: http://msdn.microsoft.com/en-us/library/jj218792.aspx
- If you have installed PowerPivot, Open Add/Remove Programs. (Click Start. Click Settings. Click Control Panel. Click Add/Remove Programs.)
- Right click and repair the PowerPivot installation.
- Open the following location: C:\Program Files\Microsoft SQL Server\110\Tools\PowerPivotTools\SPAddinConfiguration\Resources\
- Find PowerPivotFarmSolution.wsp. Rename this file extension to .cab. Extract the contents.
- Find the PowerPivotDbLogic.sql and PowerPivotDbSchema.sql files. Copy them to a familiar location.
- Copy the PowerPivotDbLogic.sql and PowerPivotDbSchema.sql files to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\SQL. Ad-hoc create the appropriate folder structure as required.
- Retry to create the PowerPivot Service Application from Central Admin. Should work.
You might encounter this error when you are doing a pretty routine operation; resetting your search index.
The exact error is:
System.InvalidOperationException: No system manager locations set, search application might not be ready yet.
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
at Microsoft.Office.Server.Search.Internal.UI.SearchReset.OnClickReset(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The stack trace unfortunately does not give you a lot to go on, just saying its resetting Ceres. The InvalidOperationException message is not really helpful because the service app could already be properly stood up.
After looking at it for a while, it is because of a time skew between the VM server and the host machine. Do’h! So make sure that the time is synced between the two environments!