Powershell 4.0 Transcript is not capturing output of Write-Host statements

I have created following script(test.ps1) and I am executing it from command line as "powershell .\test.ps1"

Write-Host(Start-Transcript -Path "D:\logs.txt")
$remoteScript = {
    Write-Host "Remote Log"
Invoke-Command -ConnectionUri $uri -Credential $creds -ScriptBlock $remoteScript
Write-Host "Local Log"

However in the log file generated after executing script, I do not see the log statement either remote or local. This used to work with Powershell 3.0 but recently I upgraded to Powershell 4.0 and it stopped working.

Has anyone faced similar issue or is aware of any other way to capture output from remote and local commands?




  • Here is a hotfix from Microsoft to resolve this issue:


    It is also discussed here, in Technet


    From the Hotfix site:

    On a server that's running Windows Server 2012 R2, you encounter one or more of the following issues when you use PowerShell:

    • Issue 1

    The Start-Transcript cmdlet does not capture write-host calls, as seen in the following script example:

    Start-Transcript -path $env:TEMP\transcript.txt
    Write-Host Hello World

    Get-Content $env:TEMP\transcript.txt
    In this case, "Hello World" does not appear in the transcript.txt file as expected.