8000 Fix for implicit remote regression in restricted session by PaulHigin · Pull Request #4222 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Fix for implicit remote regression in restricted session #4222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2017
Merged

Fix for implicit remote regression in restricted session #4222

merged 3 commits into from
Jul 14, 2017

Conversation

PaulHigin
Copy link
Contributor

Issue #4195

PowerShell 5.1 Get-FormatData has a new required parameter (PowerShellVersion) which was not included in restricted sessions. So Import-PSSession fails when trying to use the parameter.

Fix is to add this parameter to the restricted session Get-FormatData proxy function.

Repro:

# Create and register a restricted session endpoint on local machine with PS 5.1
New-PSSessionConfigurationFile -Path c:\restricted.pssc -SessionType RestrictedRemoteServer
Register-PSSessionConfiguration -Path C:\restricted.pssc -Name restricted -Force
 
# Create and import a session instance
$s = New-PSSession -config restricted 
Import-PSSession -Session $s -AllowClobber
 
Result:
Import-PSSession : Running the Get-Command command in a remote session reported the following error: A parameter
cannot be found that matches parameter name 'PowerShellVersion'..
At line:1 char:1
+ Import-PSSession -Session $s -AllowClobber
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Import-PSSession], RuntimeException
    + FullyQualifiedErrorId : ErrorFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand

@PaulHigin PaulHigin added WG-Remoting PSRP issues with any transport layer Issue-Bug Issue has been identified as a bug in the product OS-Windows labels Jul 11, 2017
@PaulHigin PaulHigin added this to the 6.0.0-HighPriority milestone Jul 11, 2017
@PaulHigin PaulHigin requested a review from TravisEz13 July 11, 2017 18:44
@PaulHigin
Copy link
Contributor Author

There is no test associated with this fix because we have not ported implicit remoting tests yet.
I have created Issue #4223 to track this.

@daxian-dbw
Copy link
Member
daxian-dbw commented Jul 13, 2017

@PaulHigin we have implicit remoting tests at https://github.com/PowerShell/PowerShell/blob/master/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1
Can you please take a look to see if that's what you looked for?
If it is, could you please add the corresponding tests for this PR as well?

@PaulHigin
Copy link
Contributor Author

@daxian-dbw Thanks!, I didn't realize these tests were ported. I'll create a test for this fix.


if ($originalDefaultParameters -ne $null)
{
$PSDefaultParameterValues = $originalDefaultParameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be $global:PSDefaultParameterValues = $originalDefaultParameters. Otherwise, you are just defining a variable in the local scope.

@TravisEz13
Copy link
Member

restarted AppVeyor CI due to MyGet failure

@daxian-dbw daxian-dbw merged commit 7fa0dd0 into PowerShell:master Jul 14, 2017
@PaulHigin PaulHigin deleted the ImplicitRemoteBug branch July 14, 2017 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product OS-Windows WG-Remoting PSRP issues with any transport layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0