Customizing PowerShell Prompt via $Profile

Customizing PowerShell Prompt via $Profile
If you want to customize PowerShell’s interactive experience with a personalized prompt, you need to modify the $profile variable.
 

<#Create a new profile (and overwrite one if it already exists):#>
 New-Item -type file -force $profile

<#To edit your profile:#>

notepad $profile
 
<#To see your profile file:#>

 
Get-ChildItem $profile
<#Once you create a profile script,add a function called Prompt
PowerShell displays the output of this function as your command-line prompt.#>

 
function Prompt {"PS: Vinith-Server $(get-date)>"}
 <#To Immediately reflect the changes made to your profile run#>

 
. $profile

 

<#Which would show up like below#>

PS: Vinith-Server 11/13/2012 08:20:36>

<#If you again want to revert back to Default settings, open profile script and remove the entries which you made and save it and close and re-open powershell#>

notepad $profile

 

<# i see its all back to normal #>

 

 

Share this post

Post Comment