On a brand new production server after installing and configuring SharePoint 2013, running the SharePoint 2013 Management Shell produced an alarming error:
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
'System.Management.Automation.CustomPSSnapIn'.
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
dPSSnapinCommand
I searched the web for an answer and found some posts in forums. Essentially their answer was to rebuild the server because they installed and reinstalled software and/or upgraded the operating system. In my case, this was brand new - there was no way this was because of an upgrade or software being installed incorrectly.
After trying to repair SharePoint 2013, running the Products Configuration Wizard, uninstalling/reinstalling SharePoint 2013, removing server roles, adding server roles, etc. etc. etc., I finally took a step back and figured out the problem.
I thought this must be an issue with PowerShell and not SharePoint - it turns out it was. To resolve this issue, all you need to do is uninstall and reinstall the Windows Management Framework 3.0.
Simply open the Control Panel on your server and click on programs:
Next, open browser and navigate to the WMF 3.0 download in the Microsoft Download Center. Download and reinstall Windows6.1-KB2506143-x64.msu:
Restart the server if directed. Run SharePoint 2013 Management Shell and the issue is resolved!!!
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
'System.Management.Automation.CustomPSSnapIn'.
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
dPSSnapinCommand
After trying to repair SharePoint 2013, running the Products Configuration Wizard, uninstalling/reinstalling SharePoint 2013, removing server roles, adding server roles, etc. etc. etc., I finally took a step back and figured out the problem.
I thought this must be an issue with PowerShell and not SharePoint - it turns out it was. To resolve this issue, all you need to do is uninstall and reinstall the Windows Management Framework 3.0.
Simply open the Control Panel on your server and click on programs:
On the Programs screen, click View installed updates:
Locate Microsoft Windows Management Framework 3.0 (KB2506143), right click the entry, and select Uninstall:
Run through the uninstall, restarting the server if directed.Next, open browser and navigate to the WMF 3.0 download in the Microsoft Download Center. Download and reinstall Windows6.1-KB2506143-x64.msu:
Restart the server if directed. Run SharePoint 2013 Management Shell and the issue is resolved!!!
Thanks Mann, after days and weeks of frustration.
ReplyDeleteGlad this helped! Thanks!
DeleteThis is awesome thanks!
ReplyDeleteGreat! Thanks for the comment.
DeleteWorks Great !
ReplyDeleteThank you !
Glad this helped!!
DeleteYou are a life-saver. Many many thanks!
ReplyDeleteThank you very much!!!!
ReplyDeleteThis dosent work on Windows Server 2012. Any update for that?
ReplyDeleteSorry I have no idea. I haven't encountered this issue ever since.
DeleteSorry I have no idea. I haven't encountered this issue ever since.
DeleteI tried Windows management Framework 4.0 but get an error
Delete"[Window Title]
Windows Update Standalone Installer
[Main Instruction]
Windows Update Standalone Installer
[Content]
Installer encountered an error: 0x80096002
The certificate for the signer of the message is invalid or not found.
[OK]"
This dosent work on Windows Server 2012 R2 either. Any updates? Need help
ReplyDelete