Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I like to define the env variable PROMPT as $p$_$g so prompt starts in a new line.

But seems to be not applying to my PowerShell prompt :-(

dir function:/ shows that a name "prompt" is already defined.

Any way I can get my prompt customized in a PowerShell console, without messing up with the already defined "prompt" name?

share|improve this question
up vote 14 down vote accepted

The prompt function is just the default prompt supplied by Powershell. If you put a new prompt function into your profile, it will overwrite the existing one - but if you remove the custom definition in your profile, the previous function will be used again.

Edit your profile with:

notepad $profile

Then add your custom prompt function:

function prompt {

Restart powershell and you will have your new prompt.

To revert, just edit $profile again and remove the new function.

share|improve this answer
A note to add: You can do pretty much anything in your prompt function, including colorized output (with Write-Host), &c. However, keep in mind that it must return something. If you only do Write-Host -Fore Green -no "PS $pwd> " in there you'll get a prompt like PS Home:\> PS> since PowerShell assumes that an empty prompt wasn't what you meant. In those cases you can output a character more than needed and return "b"` (the backspace character). – Joey May 30 '10 at 9:34
Johannes: can't believe I forgot about $pwd, thanks! – MattB May 30 '10 at 13:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.