...
Example of Logging with PowerShell Start-Transcript
Writes the log to a file with date and time. For example: RunLog_2023_08_23@12-30.txt.
The file path is based on the location of the script. For example: <path-to-the-script-file>\Run_Logs\ RunLog_2023_08_23@12-30.txt.
Code Block | ||
---|---|---|
| ||
######### Start Logging ######################################### $DateTimeStr = Get-Date -UFormat %Y-%m-%d@%H-%M # date-time string for log file name [string]$RunLogsPath = "$($PSScriptRoot)\Run_Logs" # path for log file created below [string]$Transcript_FileRef = "$($RunLogsPath)\RunLog_$DateTimeStr.txt" Start-Transcript -Path $Transcript_FileRef -Append -Verbose |
...
/wiki/spaces/DS/pages/521732097 How to run PowerShell scripts instead of .bat files.