PowerShell / WindowsCompatibility

Module that allows Windows PowerShell Modules to be used from PSCore6
Other
137 stars 33 forks source link

Critical Bug: Remote Sessions Fail #23

Closed markekraus closed 5 years ago

markekraus commented 6 years ago

I was writing up some quick start guides and when I went to validate how remote modules worked I discovered the remoting scenario is broken. Repro:

$Credential = Get-Credential
Initialize-WinSession -ComputerName REMOTECOMPUTER -Credential $Credential
Invoke-WinCommand -ScriptBlock { $env:COMPUTERNAME }

Expected result:

REMOTECOMPUTER

actual result:

LOCALCOMPUTER

It looks like commands call Initialize-WinSession and if -ComputerName and -ConfigurationName are not passed to the outer command by the user, The defaults are then used, which initializes or returns the local computer session.

We should adjust the logic in Initialize-WinSession to not clobber the exiting remote session with a local session when the module commands are called without the additional paramters, or Initialize-WinSession should update the $script:DefaultComputerName and $script:DefaultConfigurationName when it initializes a new session.

BrucePay commented 5 years ago

This has been fixed by the associated PR.