Windows 8和 Windows Server 2012都帶有 Windows PowerShell 3.0
Windows PowerShell 3.0使用的是 .netframework 4.0
執行 .netframework 2.0指令碼會出錯
比如 sharepoint 2010
不能訪問本機伺服器場。沒有註冊帶有FeatureDependencyId 的 Cmdlet。PS C:\Users\luozhuang> Remove-SPWebApplication -identity http://win-kfmi99jvfn9/ -ConfirmRemove-SPWebApplication : Microsoft .Net Runtime 的版本 4.0.30319.18010 不支援Microsoft SharePoint。所在位置 行:1 字元: 1+ Remove-SPWebApplication -identity http://win-kfmi99jvfn9/ -Confirm+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Share...PWebApplication: SPCmdletRemoveSPWebApplication) [Remove-SPWebApplication],PlatformNotSuppo rtedException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRemoveSP WebApplicationPS C:\Users\luozhuang>
怎麼辦,上網查查,說是
登錄機碼:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine
修改RuntimeVersion為你想使用的.NET Framework 版本即可。
結果行不通
解決方案:
Server Manager-> Add Roles and Features. 就是進伺服器管理-〉添加角色和功能,對應win2012,如果是win8就進控制台-〉卸載或更改程式-〉開啟或關閉windows 功能
選擇安裝下面兩個功能
.NET Framework 3.5
Windows PowerShell 2.0
安裝好了以後,對於需要運行 .netframework 2.0 腳步需要這樣使用:
PowerShell.exe -Version 2
比如修改sharepoint 2012 那個捷徑為:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "