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
Leave a comment