Snapin无法加载,Cmdlet现在针对错误的PowerShell版本,如何发生这种情况?
-
10-12-2019 - |
题
我继承了一个服务器-2008 SharePoint-2010开发环境,SharePoint Snapin无法加载;警告...
Add-PSSnapin : Incorrect Windows PowerShell version 3.0. Windows PowerShell
version 2.0 is supported in the current console.
.
我跟随所有记录的补救措施:
- 卸载WMF 3.0和KB2506146
- 执行powershell.exe与“-version 2.0”参数
- 从PowerShell Config 中删除对.NET 4.0的引用
Snapin无法加载和仍然相同的警告“Windows PowerShell版本不正确”,因此我确认了该版本。它看起来很好...
.PS C:\Users\Administrator> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
所以我检查了snapin ...
.PS C:\Users\Administrator> Get-PSSnapIn -Registered Name : Microsoft.SharePoint.PowerShell PSVersion : 3.0 Description : Register all administration Cmdlets for Microsoft SharePoint Server
psversion是3.0 ??? Snapin的PSVersion在所有其他机器上读取1.0。由于4.0 .NET Framework,不会在3.0中运行。我怎么能改变这件事?这样它目标的powershell兼容版本? 感谢您提供的任何帮助。
解决方案
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.