Monday, March 25, 2013

SharePoint 2013 Management Shell Cannot load Snap-In Issue Resolved

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:

 
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!!!


14 comments:

  1. Thanks Mann, after days and weeks of frustration.

    ReplyDelete
  2. This is awesome thanks!

    ReplyDelete
  3. Works Great !

    Thank you !

    ReplyDelete
  4. You are a life-saver. Many many thanks!

    ReplyDelete
  5. Thank you very much!!!!

    ReplyDelete
  6. This dosent work on Windows Server 2012. Any update for that?

    ReplyDelete
    Replies
    1. Sorry I have no idea. I haven't encountered this issue ever since.

      Delete
    2. Sorry I have no idea. I haven't encountered this issue ever since.

      Delete
    3. I tried Windows management Framework 4.0 but get an error

      "[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]"

      Delete
  7. This dosent work on Windows Server 2012 R2 either. Any updates? Need help

    ReplyDelete