Windows PowerShell 3.0 使用 .netframework 2.0

  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/
 -Confirm
Remove-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
   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 ' "

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值