PowerShell – Environment Customization – Prompt

Background

By default, when one initiates Powershell, the environment prompt takes upon the current folder.

Default Prompt

Customization

Outline

  1. Determine the name of our Powershell Profile file
  2. Edit existing file or create a new one
    • Add function called prompt

Get Profile file

Syntax

powershell -Command "Write-Host('Profile file is {0}', $profile);"

Output

Textual


C:\Users\dadeniji\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

 

Edit Profile file

Sample


function prompt
{
	[string] $prompt;
	
	$prompt = ">";
	
	return($prompt);
	
}

Validate

In a new command shell, launch powershell…

And, irrespective of our current folder, we will be greeted with “PS>”.

References

  1. Microsoft
    • Microsoft Technet
      • Scripting Guy
        • Change the Powershell Prompt
          Link
  2. Robert Sheldon
    • ITProToday
      • PowerShell Basics: Console Configuration
        How to customize the PowerShell console
        Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s