Powershell - Problem with Start-transcript using remoting

Posted by Sanjeev on Stack Overflow See other posts from Stack Overflow or by Sanjeev
Published on 2011-01-05T17:53:04Z Indexed on 2011/01/05 17:53 UTC
Read the original article Hit count: 275

I have a file transcript-test.ps1 with below contents

$log="TestLog{0:yyyyMMdd-HHmm}" -f (Get-Date) $logfile = 'C:\logs\'+$log+'.txt' Start-transcript -path $logfile -force Echo "To test if this message gets logged" Write-host "To test if this message gets logged" logged" Stop-transcript

I try to run the script from lets say "box1" and the log file contains the below contents

********** Windows PowerShell Transcript Start Start time: 20110105114050 Username : domain\user Machine : BOX1 (Microsoft Windows NT 5.2.3790 Service Pack 2) ********** Transcript started, output file is C:\logs\TestLog20110105-1140.txt

This should get logged in the log file C:\logs\TestLog20110105-1140.txt

********** Windows PowerShell Transcript End End time: 20110105114050


When I run the same script from another machine using below script I don't see any messages in the log file

Invoke-command {powershell.exe -ExecutionPolicy Unrestricted -NoProfile -File C:\in ll\transcript-test.ps1} -computername box1 -credential $credential

Contents of log file :

********** Windows PowerShell Transcript Start Start time: 20110105114201 Username : OX\qauser Machine : MODESIGNAU1 (Microsoft Windows NT 5.2.3790 Service Pack 2)


********** Windows PowerShell Transcript End End time: 20110105114201


Is there anyway to log the messages from the script to log file when invoked remotely ?

Thanks! Sanjeev

© Stack Overflow or respective owner

Related posts about powershell-v2.0

Related posts about powershell-remoting