0

I have a script that I need to run on a set of computers. I have it logging everything it does using the built-in transcript feature. This works fine when running the script via normal means. When the script is run inside a PSRemoting session, I see the output on my terminal but the resulting transcript file is blank. I must assume this is because the standard output is being redirected to the remote session in a way that isn't captured by the transcript command.

Is there a simple way to keep using the transcript feature and have it work inside a PSRemoting session?

EXAMPLE SCRIPT:

#Run-My-Script.ps1
Set-PSDebug -Trace 1
$timeStamp = $(Get-Date -Format yyyyMMddTHHmmss)
$localTranscriptFile = "$PSScriptRoot\$env:COMPUTERNAME-ScriptOutput-$timeStamp.txt"
Start-Transcript -path $localTranscriptFile -append
# Run some commands
Write-Output "Important information to save in the log file."
Stop-Transcript
Set-PSDebug -Trace 0

Run that script with PSRemoting:

Enter-PSSession ComputerName
.\Run-My-Script.ps1

The resulting transcript is written with the header and footer, but no contents.

0

You must log in to answer this question.

Browse other questions tagged .