admin 管理员组

文章数量: 1184232

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 
 -Confirm
Remove-SPWebApplication : Microsoft .Net Runtime 的版本 4.0.30319.18010 不支持
Microsoft SharePoint。
所在位置 行:1 字符: 1
+ Remove-SPWebApplication -identity  -Confirm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...PWebApplication:
   SPCmdletRemoveSPWebApplication) [Remove-SPWebApplication],PlatformNotSuppo
   rtedException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRemoveSP
   WebApplication
PS 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 ' "

本文标签: 为什么还 系统 功能