Forcing version 2 on remote session for SharePoint management using Powershell

徘徊边缘 提交于 2020-01-04 13:35:16

问题


It seems that SharePoint 2010 is still incompatible with PowerShell version 3.0.

I am already aware that it is possible to force compatibility by executing PowerShell with the -v 2 switch, but is there a way to force this compatibility mode when using a remote session via PSSession as using a remote desktop is quite impractical just to launch a shell?


回答1:


If you start the client PowerShell with -v 2. Then outgoing remote sessions should use v2 on the remote end automatically.

Update: it appears I am mistaken - I think in fact I had discussed this with the PowerShell team, but apparently it's not fixed. Anyway, you can create a session configuration on the server that is forced to version 2.0:

PS> $psversiontable

Name                           Value
----                           -----
PSVersion                      3.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.18010
BuildVersion                   6.2.9200.16434
PSCompatibleVersions           {1.0, 2.0, 3.0}
PSRemotingProtocolVersion      2.2

PS> Register-PSSessionConfiguration -PSVersion '2.0' -Name "powershell2"

Accept all of the prompts. Now, you must pass the name of the new remote session configuration when invoking from the client side (in this example, the client and server are the same machine: my desktop)

PS> icm localhost -ConfigurationName powershell2 { $psversiontable }

Name                           Value
----                           -----
PSRemotingProtocolVersion      2.1
BuildVersion                   6.1.7600.16385
PSCompatibleVersions           {1.0, 2.0}
PSVersion                      2.0
CLRVersion                     2.0.50727.6400
WSManStackVersion              2.0
SerializationVersion           1.1.0.1

As you can see, the remote endpoint is running 2.0.

I hope this helps.



来源:https://stackoverflow.com/questions/16483764/forcing-version-2-on-remote-session-for-sharepoint-management-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!