mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix Start-Transcript error when $Transcript is a PSObject wrapped string (#24963)
This commit is contained in:
@@ -177,7 +177,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
_outFilename = (string)value;
|
||||
_outFilename = (string)PSObject.Base(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,11 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
|
||||
$outputFilePath = Join-Path $TestDrive "PowerShell_transcript*"
|
||||
ValidateTranscription -scriptToExecute $script -outputFilePath $outputFilePath
|
||||
}
|
||||
It "Should create Transcript file with 'Transcript' preference variable" {
|
||||
# Casting to PSObject is necessary because Set-Variable does not automatically wrap the value in a PSObject
|
||||
$script = "Set-Variable -Scope Global -Name Transcript -Value ([PSObject]'$transcriptFilePath'); Start-Transcript"
|
||||
ValidateTranscription -scriptToExecute $script -outputFilePath $transcriptFilePath
|
||||
}
|
||||
It "Should Append Transcript data in existing file if 'Append' parameter is used with Path parameter" {
|
||||
$script = "Start-Transcript -path $transcriptFilePath -Append"
|
||||
ValidateTranscription -scriptToExecute $script -outputFilePath $transcriptFilePath -append
|
||||
|
||||
Reference in New Issue
Block a user