8

I'm on a server that is running Powershell Version 2:

PS C:\> $PSVersionTable

Name      Value
----      -----
...
PSVersion 2.0

I then create a new remote session to a different 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 to be in Version 2 for my script so I enter a session (to make it easier). I then 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 enter anything else into the console until I Ctrl-C).

I've also tried going through the Invoke-Command:

PS C:\> Invoke-Command -Session $sess -ScriptBlock { Powershell -version 2 }

and it does the same.

I've also tried to register a PSSessionConfiguration as per 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 of what I can try next?! Thanks

7
  • 5
    Whats in 2 that isn't in 3? Why is it easier? I'm honestly curious. Nov 6, 2015 at 4:00
  • 2
    One what machine did you run Register-PSSessionConfiguration... your computer or the "server"? What is the OS of the server? I just tried the steps in the technet article and it worked perfectly. My 2008 server remoted to my windows 7 machine running a 2.0 PSSessionConfiguration. Have you tried this against a different server or host?
    – Matt
    Nov 6, 2015 at 4:16
  • @RitchMelton - Alas SharePoint 2010 integration (support.microsoft.com/en-us/kb/2796733)
    – Pete
    Nov 8, 2015 at 22:39
  • 1
    @Pete: I'm sorry. I'm also sad some things cant be unseen. Nov 8, 2015 at 23:18
  • 1
    @Matt - You've answered his question. If you put it in as an answer, he can mark it so, and we won't see this as unanswered.
    – Jeter-work
    Nov 23, 2015 at 19:36

2 Answers 2

4

On what machine did you run Register-PSSessionConfiguration?. Your computer or the "server"?

You need to make the configuration on the target server. That is what you will be running the hosted PSSessionConfiguration.

I just tried the steps in the technet article and it worked perfectly. My 2008 server remoted to my windows 7 machine running a 2.0 PSSessionConfiguration.

On target server/host:

Register-PSSessionConfiguration -Name PS2 -PSVersion 2.0

Then, on the client machine, reference the 'PS2' configuration.

$s = New-PSSession -ComputerName Server01 -ConfigurationName PS2
0

I take it that the following doesn't work either:

 #Requires -version 2.0

Another kluge you could try is to create a scheduled task on the target and have the task fire off your script with Powershell.exe -version 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.