SnapIn won't load, the Cmdlets now target the wrong Powershell Version, how'd that happen?
-
10-12-2019 - |
Question
I've inherited a Server-2008 SharePoint-2010 Dev environment, the SharePoint Snapin fails to load; warning ...
Add-PSSnapin : Incorrect Windows PowerShell version 3.0. Windows PowerShell
version 2.0 is supported in the current console.
I followed all the documented remedies:
- uninstall WMF 3.0 and KB2506146
- execute PowerShell.exe with the "-version 2.0" parameter
- remove the reference to .Net 4.0 from the PowerShell config
The SnapIn fails to load and still the same warning "Incorrect Windows PowerShell version..." So I confirm the version. It looks good...
PS C:\Users\Administrator> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1
So I checked the SnapIn...
PS C:\Users\Administrator> Get-PSSnapIn -Registered
Name : Microsoft.SharePoint.PowerShell
PSVersion : 3.0
Description : Register all administration Cmdlets for Microsoft SharePoint Server
The PSVersion is 3.0??? The PSVersion for the SnapIn reads 1.0 on all other machines. And doesn't run in 3.0 because of the 4.0 .Net framework. How can I change this back? So that it targets the compatible version of PowerShell? Thanks for any help you can offer.
Solution
The registry determines the level of PS compatibility, in my case the value was 3.0, it should be 1.0. I corrected this value by editing the following key:
HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.SharePoint.PowerShell\PowerShellVersion
The initial cause of the problem was the installation of the Windows Management Framework 3.0 which installs with it PowerShell. Even after uninstalling, the registry remained incorrect and I had to edit the registry with the information above.