Hopefully I worded that title correctly.
Transcript files don't show the info I want and I need to be able to see specific events at a glance, so I am adding an additional file that I am using as a log file.
I want to have the time appended at the beginning of each line, but it simply takes the the time it retrieved at the beginning of the script and uses that over and over again.
Script:
start-transcript -path "C:\temp\transcript $(get-date -f dd-MM-yyyy).txt"
$log = "c:\temp\log $(get-date -f dd-MM-yyyy).txt"
$logtime = Get-Date -Format "hh:mm:ss"
Write-output "$logtime First line" | add-content $log
start-sleep -s 60
Write-output "$logtime Second line" | add-content $log
stop-transcript
exit
This is the output that I get, even though it sleeps for a full minute:
02:43:52 First line
02:43:52 Second line
There may very well be no way to do this, but thought I would give it a shot anyways.
Thanks for any help.