I am on a server running Powershell Version 2:
PS C:\> $PSVersionTable Name Value ---- ----- ... PSVersion 2.0
Then I create a new remote session on another computer and connect to it:
$sess = New-PSSession -ComputerName {ComputerName} -Credential $credential
It returns me the result:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { $PSVersionTable } Name Value ---- ----- ... PSVersion 3.0
However, I need Powershell for version 2 for my script, so I enter the session (to make it easier). Then I try to get Powershell to be version 2:
C:\> Enter-PSSession -Session $sess [{ComputerName}]: PS C:\> Powershell -Version 2 Windows Powershell Copyright (C) 2009 Microsoft Corporation. All rights reserverd
And then it just hangs (or at least never lets me type anything else into the console until there is Ctrl-C).
I also tried using Invoke-Command:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { Powershell -version 2 }
and he does the same.
I also tried registering the PSSessionConfiguration, as here: https://technet.microsoft.com/en-us/library/hh847899.aspx
PS C:\> Register-PSSessionConfiguration -Name PS2 -PSVersion 2.0
But I get:
Register-PSSessionConfiguration: a parameter cannot be found that matches parameter name 'PSVersion'.
Does anyone have any ideas what I can try next ?! Thanks
Pete
source share