diff --git a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs
index 373c4f920da..8249eb33d01 100644
--- a/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs
+++ b/src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs
@@ -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 =
@@ -463,6 +467,7 @@ private void LogTranscriptHeader(System.Management.Automation.Remoting.PSSenderI
DateTime.Now,
username,
runAsUser,
+ psConfigurationName,
Environment.MachineName,
Environment.OSVersion.VersionString,
String.Join(" ", Environment.GetCommandLineArgs()),
diff --git a/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs b/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs
index 986d280d96c..04e76936831 100644
--- a/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs
+++ b/src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs
@@ -162,6 +162,11 @@ public PSPrimitiveDictionary ApplicationArguments
internal set { _applicationArguments = value; }
}
+ ///
+ /// "ConfigurationName" from the sever remote session
+ ///
+ public string ConfigurationName { get; internal set; }
+
#endregion
}
diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs
index da2767aa274..41d7ce78f56 100644
--- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs
+++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs
@@ -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,
diff --git a/src/System.Management.Automation/resources/InternalHostUserInterfaceStrings.resx b/src/System.Management.Automation/resources/InternalHostUserInterfaceStrings.resx
index b607e77300e..7ee332f2cf6 100644
--- a/src/System.Management.Automation/resources/InternalHostUserInterfaceStrings.resx
+++ b/src/System.Management.Automation/resources/InternalHostUserInterfaceStrings.resx
@@ -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}
**********************
diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
index a0b0df0ac74..c35f42bf4d0 100644
--- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
+++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1
@@ -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
+ }
+ }
+
}
\ No newline at end of file