我的服务器上运行PowerShell的版本2:运行远程PowerShell会话版本2
PS C:\> $PSVersionTable
Name Value
---- -----
...
PSVersion 2.0
我然后创建一个新的远程会话到另一台计算机,并连接到它:
$sess = New-PSSession -ComputerName {ComputerName} -Credential $credential
它返回我的结果:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { $PSVersionTable }
Name Value
---- -----
...
PSVersion 3.0
不过,我需要PowerShell将在第2版为我的剧本,所以我恩特召开会议(使其更容易)。然后我试图让PowerShell的是第2版:
C:\> Enter-PSSession -Session $sess
[{ComputerName}]: PS C:\> Powershell -Version 2
Windows Powershell
Copyright (C) 2009 Microsoft Corporation. All rights reserverd
然后它只是挂起(或至少从来没有让我输入其他任何内容到控制台,直到我按Ctrl-C)。
我也尝试去通过调用命令:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { Powershell -version 2 }
和它相同。
我也尝试注册一个PSSessionConfiguration按这里:https://technet.microsoft.com/en-us/library/hh847899.aspx
PS C:\> Register-PSSessionConfiguration -Name PS2 -PSVersion 2.0
,但我得到:
Register-PSSessionConfiguration: a parameter cannot be found that matches parameter name 'PSVersion'.
有没有人有什么我可以尝试下什么想法? 感谢
什么在2不是3?为什么更容易?我真的很好奇。 –
你运行了什么机器“Register-PSSessionConfiguration”......你的电脑或“服务器”?服务器的操作系统是什么?我只是尝试了technet文章中的步骤,它完美地工作。我的2008服务器远程运行我的Windows 7机器运行2.0 PSSessionConfiguration。你是否尝试过使用不同的服务器或主机? – Matt
@RitchMelton - 唉SharePoint 2010集成(https://support.microsoft.com/en-us/kb/2796733) – Pete