Powershell Transcript logging

Posted: March 29, 2012 in Powershell
Tags: , ,


I have recently started keeping a track of all my PowerShell.

Just a nice simple update.

So, I decided to create a “simple” PowerShell script that would keep a track of all my transcripts. The script would create a file name based on date and place the transcript file in a folder of your choice, this is hard-coded in the script and can be easily modified.

Hope you like it and find it useful.

$date =Get-Date
$filepath = "C:\PSTranscripts"
$hour = ($date.Hour).tostring()
$minute = $date.Minute
$file = $hour + "H" + $minute + "M" +  ".txt"
$newpath = $filepath + "\" + $date.Day + "-" + $date.Month +"-" + $date.year
$fullpath = $filepath + "\" + $date.Day + "-" + $date.Month +"-" + $date.year +"\" + $file
New-Item -ItemType Directory -Path $newpath -ErrorAction SilentlyContinue
Start-Transcript -Path $fullpath

I had this as part of my admin PowerShell Profile, more info on the PowerShell Profile here

I am using the script above as .ps1 script for my day to day account.

Follow me

facebook-small32225222 twitter-small32225222


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s