Small Powershell scripting tip

By | 2010-06-16

Want to log the output of your powershell script?
use “Start-Transcript”!

Top of your powershell script:

## Start logging
$LogTime = Get-Date -Format yyyy-MM-dd_h-mm
$LogFile = "$env:USERPROFILEDesktopDeploy-$LogTime.rtf"
Start-Transcript -Path $LogFile -Force

and put this at the end of your script:

Invoke-Item $LogFile

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.