Author Posts

January 1, 2012 at 12:00 am

by selasley at 2013-05-01 09:54:57

I wondered if someone might confirm the following.

Using a windows 8 machine with Powershell v3...
[code2=powershell]$sessions = New-PSSession -ComputerName comp-with-PSv2,localhost
Get-PSSession -ComputerName comp-with-PSv2
Get-PSSession -ComputerName localhost[/code2]
...the second command returns null (when remote box has Powershell v2) while the third returns the specified session

Using a Windows 7 machine with Powershell v2...
[code2=powershell]$sessions = New-PSSession -ComputerName comp-with-PSv3,localhost
Get-PSSession -ComputerName comp-with-PSv3
Get-PSSession -ComputerName localhost[/code2]
...both the second and third commands return the associated sessions

I'm assuming that this somehow relates to this from the Get-PSSession help in V3?
"Beginning in Windows PowerShell 3.0, PSSessions are stored on the computers at the remote end of each
connection. To get the sessions on the specified computers, Windows PowerShell creates a temporary connection
to each computer and runs a Get-PSSession command."

I noted this oddity while following along with MonthofLunchesV3 Chapter 20. The included instructions on p.250 failed for me on v3 (pulling the session via a parenthetical command when the remote machine had v2). Also worthy of note is that the -ComputerName parameter of Get-PSSession accepts wildcards on v2 and not v3. The instructions on p.252 thus fail as well when using v3. At least that is what seemed to happen to me.

by DonJ at 2013-05-04 08:49:34

Correct. There's a difference in functionality between v2 and v3.