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"
Write-Host(Stop-Transcript)
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?
Thanks,
Gaurav