How do we customize the PowerShell Profile to start the transcript
I was thinking about this for a long time, how do I Customize my PowerShell to have the transcript Started and to have the user name displayed on the Tittle of the PowerShell window.?
Some other thoughts came too in this Can I customize my Foreground ?
How do I push this to all the PowerShell Users in my Domain?
Well I was finally able to go ahead and figure this out :)
To do this we need to have a to add Profile.ps1 in the following location
C:\Windows\System32\WindowsPowerShell\v1.0\
Now how do we do this ?
Well I thought of using the Group Policy to do this
Now after you have selected the files we need to add two things
1. Source File(s): Add the UNC path of the file.
2. Destination File : C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1
The most important thing is what do we have in the Profile.ps1
Here is an Example where I have added the Domain\alias in the Title Bar and have started the Transcript in the session.
$c=(get-WmiObject -Class Win32_UserAccount -Filter "Name='$env:username' and Domain='$env:userdomain'").Caption >>>>> Here is where I get the Domain Name and User Name who has logged in
$host.UI.RAWUI.Windowtitle= "$c"
Set-ExecutionPolicy remotesigned -confirm:$false
start-transcript -path ("$env:temp"+ (get-date -format ddmmyyHHmm)+".txt") -force -noclobber >>>>>>>>> Here is where I have started the transcript
How do we see the PowerShell before we went ahead and added the Profile.Ps1
Now Let us see the PowerShell after we pushed the Profile.ps1 using the group policy
As we can see the domain name and the transcript already started with the PowerShell window.
Does this work with Exchange or Any other PowerShell : Yes if the Profile path is C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1.
I would be working on the adding the transcript file to an UNC path so that it is easier for the administrators to go ahead and manage the files.
-Written By Naveen Vasudevan