Windows PowerShell 3.0 使用 .netframework 2.0

來源:互聯網
上載者:User

  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 ' "
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.