Related issue: #4645
run.ps1
Start-Transcript -Path (Join-Path $PSScriptRoot 'transcriptdata.txt')
$InformationPreference = 'SilentlyContinue'
Write-Information 'SilentlyContinue'
$InformationPreference = 'Continue'
Write-Information 'LoudlyContinue'
Stop-Transcript
Steps to reproduce
Expected behavior
transcriptdata.txt should contains only LoudlyContinue
Actual behavior
transcriptdata.txt contains only SilentlyContinue
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.1
PSEdition Core
GitCommitId v6.1.0-preview.1
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Investigation
The problem is in if/else statement which starts here:
|
if ((record.Tags.Contains("PSHOST") && (!record.Tags.Contains("FORWARDED"))) |
|
|| (preference == ActionPreference.Continue)) |
and has a continuation here:
|
else |
|
{ |
|
// Only transcribe informational messages here. Transcription of PSHost-targeted messages is done in the InternalUI.Write* methods. |
|
CBhost.InternalUI.TranscribeResult(StringUtil.Format(InternalHostUserInterfaceStrings.InformationFormatString, record.ToString())); |
|
} |
Transcription of Write-Host commands are handled in InternalUI.Write* methods as the comment suggests. These commands are distinguished by "PSHOST" tag.
Transcription of Write-Information commands is supposed to take place in the else statement but code in this statement is being executed only if
(!record.Tags.Contains("PSHOST") || record.Tags.Contains("FORWARDED"))
&&
preference != ActionPreference.Continue)
This condition is invalid. Correct condition is:
!record.Tags.Contains("PSHOST")
&&
preference == ActionPreference.Continue)
PR pending...
Related issue: #4645
run.ps1
Steps to reproduce
Expected behavior
Actual behavior
Environment data
Investigation
The problem is in if/else statement which starts here:
PowerShell/src/System.Management.Automation/engine/MshCommandRuntime.cs
Lines 757 to 758 in 948532a
and has a continuation here:
PowerShell/src/System.Management.Automation/engine/MshCommandRuntime.cs
Lines 824 to 828 in 948532a
Transcription of Write-Host commands are handled in InternalUI.Write* methods as the comment suggests. These commands are distinguished by "PSHOST" tag.
Transcription of Write-Information commands is supposed to take place in the else statement but code in this statement is being executed only if
This condition is invalid. Correct condition is:
PR pending...