Hello All,
In our project we need to write lots of Powershell scripts. So just finding the ways to maintain logs in Powershell scripts.
There is a Powershell command “Start-Transcript” which allows you to write into a log file.
Syntax:
Start-Transcript <Log File Path>
<Log File Path>: Log file path in which logs are maintained.
After this command we can use either write-output or write-host. Everything used with these commands is get logged into log file.
Whenever if we want to stop the maintain logs there is command “Stop-Transcript”.
Example:
$logFilePath = “c:\logfile.log” #Log File Path contains folder name and file name.
Start-Transcript $ logFilePath
write-output "Logging Started”
Stop-Transcript
Thanks!
Br,
Prasham

Prasham SabadraPosted Feb 24, 2015, 12:44 AM
Thanks All!
Rahul Kumar SaxenaPosted Feb 23, 2015, 9:22 AM
Knowledgeable....
Sibeesh VenuPosted Feb 23, 2015, 7:25 AM
Good One.