If you’re like me and use Windows PowerShell frequently, it might be worth looking at customizing your default PowerShell profile. There are times where I may need to look back at previous scripts I’ve run -even long after the Shell window has closed. That is why I use the Transcript function. This feature logs all of the activity in every PowerShell session. Since I have it using the -append switch, I’ve modified the script to help separate sessions within the log. Within your C:\Users\”username”\Documents folder, create another folder called “WindowsPowerShell”. Within there, create a .ps1 file named, “Microsoft.PowerShell_profile.ps1”.
My preferences are for a Black window with classic green characters. I also like to start off in my C:\Scripts folder. Lastly, I like my PowerShell logging to go into C:\PSlogging.
With that information, the .ps1 script will contain:
#Set Color Scheme
$Host.UI.RawUI.BackgroundColor = “Black”
$Host.UI.RawUI.ForegroundColor = “Green”
#Set Default Location
Set-Location C:\Scripts
#Set Logging Variables
$LogTime = Get-Date -Format “yyyy_MM_dd_hhmm”
CLS
Write-Host “Microsoft Windows 8.1 PowerShell Session Version 3. Please continue…” -ForegroundColor Blue
Start-Transcript “C:\PSlogging\transcript.log” -Append
Write-Host “================= Log Time: $LogTime =============================” -ForegroundColor Yellow
-Enjoy!