Skip to content
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
26 changes: 25 additions & 1 deletion src/System.Management.Automation/help/ProviderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,38 @@ internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)
// Does the provider know how to generate MAML.
CmdletProvider cmdletProvider = providerInfo.CreateInstance();
ICmdletProviderSupportsHelp provider = cmdletProvider as ICmdletProviderSupportsHelp;

// Under JEA sessions the resolvedProviderPath will be null, we should allow get-help to continue.
if (provider == null)
{
return null;
}

bool isJEASession = false;
if (this._executionContext.InitialSessionState != null && this._executionContext.InitialSessionState.Providers != null && providerInfo != null)
{
foreach (
Runspaces.SessionStateProviderEntry sessionStateProvider in
this._executionContext.InitialSessionState.Providers[providerInfo.Name])
{
if (sessionStateProvider.Visibility == SessionStateEntryVisibility.Private)
{
isJEASession = true;
break;
}
}
}

if (resolvedProviderPath == null)
{
throw new ItemNotFoundException(_requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
if (isJEASession)
{
return null;
}
else
{
throw new ItemNotFoundException(_requestedPath, "PathNotFound", SessionStateStrings.PathNotFound);
}
}

// ok we have path and valid provider that supplys content..initialize the provider
Expand Down
24 changes: 23 additions & 1 deletion test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Describe "New-PSSession basic test" -Tag @("CI") {
}

Describe "JEA session Transcprit script test" -Tag @("Feature", 'RequireAdminOnWindows') {
It "Configuration name should be in the transcript header" {
It "Configuration name should be in the transcript header" -Pending {
[string] $RoleCapDirectory = (New-Item -Path "$TestDrive\RoleCapability" -ItemType Directory -Force).FullName
[string] $PSSessionConfigFile = "$RoleCapDirectory\TestConfig.pssc"
[string] $transScriptFile = "$RoleCapDirectory\*.txt"
Expand All @@ -30,5 +30,27 @@ Describe "JEA session Transcprit script test" -Tag @("Feature", 'RequireAdminOnW
Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
}
}

}


Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') {
It "Get-Help should work in JEA sessions" -Pending {
[string] $RoleCapDirectory = (New-Item -Path "$TestDrive\RoleCapability" -ItemType Directory -Force).FullName
[string] $PSSessionConfigFile = "$RoleCapDirectory\TestConfig.pssc"
try
{
New-PSSessionConfigurationFile -Path $PSSessionConfigFile -TranscriptDirectory $RoleCapDirectory -SessionType RestrictedRemoteServer
Register-PSSessionConfiguration -Name JEA -Path $PSSessionConfigFile -Force -ErrorAction SilentlyContinue
$scriptBlock = {Enter-PSSession -ComputerName Localhost -ConfigurationName JEA; Get-Help Get-Command; Exit-PSSession}
$helpContent = & $scriptBlock
$helpContent | Should Not Be $null
}
finally
{
Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
Remove-Item $RoleCapDirectory -Recurse -Force -ErrorAction SilentlyContinue
}
}

}