PowerShell 3.0 Sharepoint脚本无法运行。

5
今天我的PowerShell更新到了3.0版本。这个版本是基于和使用.NET运行时4.0构建的。Sharepoint 2010 cmdlets需要.NET 3.5,并且在4.0下无法工作。有没有人有想法如何让脚本工作?
我收到了这个错误: Remove-SPSite:Microsoft SharePoint不支持Microsoft .Net Runtime 4.0.30319.296版本。
4个回答

8

尝试使用以下命令来启动PowerShell:powershell.exe -version 2.0


您还可以编辑/创建一个快捷方式来启动V2中的SharePoint命令模块:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -NoExit "& 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1'" - kravits88
无法用脚本 $w = get-spwebapplication 运行,仍然显示错误:PlatformNotSupported (4.0 runtime)。 - Philipp Munin

0
今天我也遇到了一些问题,但这个方法对我很有效。
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -version 2.0 -NoExit  " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

起初我认为可能是因为空格导致它无法工作,但您可以始终使用$psversiontable进行检查,并确保CLRVersion为2.0.50727.5466。


0

本文是关于PowerGUI的。在C:\Windows\System32\WindowsPowerShell\v1.0中没有powershell.exe.config配置文件。 - Ivan

0
在脚本顶部键入“PowerShell -v 2”(不带引号)。然后,在第二次运行时使用#进行注释,如果脚本挂起。这将加载PowerShell版本2,并且您应该能够将其用于SharePoint。只需键入“Exit”即可返回PowerShell v3。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接