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
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ private void LogTranscriptHeader(System.Management.Automation.Remoting.PSSenderI
psVersionInfo.AppendLine(versionKey + ": " + valueString);
}
}

string psConfigurationName = string.Empty;
if (senderInfo != null && !string.IsNullOrEmpty(senderInfo.ConfigurationName))
{
psConfigurationName = senderInfo.ConfigurationName;
}
// Transcribe the transcript header
string format = InternalHostUserInterfaceStrings.TranscriptPrologue;
string line =
Expand All @@ -463,6 +467,7 @@ private void LogTranscriptHeader(System.Management.Automation.Remoting.PSSenderI
DateTime.Now,
username,
runAsUser,
psConfigurationName,
Copy link
Contributor

Choose a reason for hiding this comment

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

psConfigurationName [](start = 20, length = 19)

I believe that this cannot be null. Please make it default to empty string.

Copy link
Member

Choose a reason for hiding this comment

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

@PaulHigin , I belive this is resolved.

Environment.MachineName,
Environment.OSVersion.VersionString,
String.Join(" ", Environment.GetCommandLineArgs()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public PSPrimitiveDictionary ApplicationArguments
internal set { _applicationArguments = value; }
}

/// <summary>
/// "ConfigurationName" from the sever remote session
/// </summary>
public string ConfigurationName { get; internal set; }

#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ internal static ServerRemoteSession CreateServerRemoteSession(PSSenderInfo sende
{
throw PSTraceSource.NewInvalidOperationException("RemotingErrorIdStrings.NonExistentInitialSessionStateProvider", configurationProviderId);
}

string shellPrefix = System.Management.Automation.Remoting.Client.WSManNativeApi.ResourceURIPrefix;
int index = configurationProviderId.IndexOf(shellPrefix, StringComparison.OrdinalIgnoreCase);
senderInfo.ConfigurationName = (index == 0) ? configurationProviderId.Substring(shellPrefix.Length) : string.Empty;
ServerRemoteSession result = new ServerRemoteSession(senderInfo,
configurationProviderId,
initializationParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ Windows PowerShell transcript start
Start time: {0:yyyyMMddHHmmss}
Username: {1}
RunAs User: {2}
Machine: {3} ({4})
Host Application: {5}
Process ID: {6}
{7}
Configuration Name: {3}
Machine: {4} ({5})
Host Application: {6}
Process ID: {7}
{8}
**********************</value>
</data>
<data name="TranscriptEpilogue" xml:space="preserve">
Expand Down
23 changes: 23 additions & 0 deletions test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,27 @@ Describe "New-PSSession basic test" -Tag @("CI") {
$_.FullyQualifiedErrorId | Should Be "InvalidOperation,Microsoft.PowerShell.Commands.NewPSSessionCommand"
}
}
}

Describe "JEA session Transcprit script test" -Tag @("Feature", 'RequireAdminOnWindows') {
It "Configuration name should be in the transcript header" {
[string] $RoleCapDirectory = (New-Item -Path "$TestDrive\RoleCapability" -ItemType Directory -Force).FullName
[string] $PSSessionConfigFile = "$RoleCapDirectory\TestConfig.pssc"
[string] $transScriptFile = "$RoleCapDirectory\*.txt"
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; Exit-PSSession}
& $scriptBlock
$headerFile = Get-ChildItem $transScriptFile | Sort-Object LastWriteTime | Select-Object -Last 1
$header = Get-Content $headerFile | Out-String
$header | Should BeLike "Configuration Name: JEA"
}
finally
{
Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
}
}

}