I created the following script (test.ps1) and I execute it from the 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 the script was executed, I do not see the log statement either remotely or locally. This was used to work with Powershell 3.0, but I recently upgraded to Powershell 4.0 and stopped working.
Has anyone encountered a similar problem, or knows of any other way to capture output from remote and local commands?
Thanks,
Gaurav
source share