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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/System.Management.Automation/engine/CommandMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,10 @@ private static CommandMetadata GetRestrictedGetFormatData()
typeNameParameter.Attributes.Add(new ValidateLengthAttribute(0, 1000));
typeNameParameter.Attributes.Add(new ValidateCountAttribute(0, 1000));

return GetRestrictedCmdlet("Get-FormatData", null, "https://go.microsoft.com/fwlink/?LinkID=144303", typeNameParameter);
// This parameter is required for implicit remoting in PS V5.1.
ParameterMetadata powershellVersionParameter = new ParameterMetadata("PowerShellVersion", typeof(Version));

return GetRestrictedCmdlet("Get-FormatData", null, "https://go.microsoft.com/fwlink/?LinkID=144303", typeNameParameter, powershellVersionParameter);
}

private static CommandMetadata GetRestrictedGetHelp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2076,3 +2076,42 @@ Describe "GetCommand locally and remotely" -tags "Feature" {
$localCommandCount | Should Be $remoteCommandCount
}
}

Describe "Import-PSSession on Restricted Session" -tags "Feature","RequireAdminOnWindows","Slow" {

BeforeAll {

# Skip tests for non Windows
if (! $IsWindows)
{
$originalDefaultParameters = $PSDefaultParameterValues.Clone()
$global:PSDefaultParameterValues["it:skip"] = $true
}
else
{
New-PSSessionConfigurationFile -Path $TestDrive\restricted.pssc -SessionType RestrictedRemoteServer
Register-PSSessionConfiguration -Path $TestDrive\restricted.pssc -Name restricted -Force
$session = New-PSSession -ComputerName localhost -ConfigurationName restricted
}
}

AfterAll {

if ($originalDefaultParameters -ne $null)
{
$global:PSDefaultParameterValues = $originalDefaultParameters
}
else
{
if ($session -ne $null) { Remove-PSSession -Session $session -ErrorAction SilentlyContinue }
Unregister-PSSessionConfiguration -Name restricted -Force -ErrorAction SilentlyContinue
}
}

It "Verifies that Import-PSSession works on a restricted session" {

$errorVariable = $null
Import-PSSession -Session $session -AllowClobber -ErrorVariable $errorVariable
$errorVariable | Should BeNullOrEmpty
}
}
0