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?

1 Answer 1


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.

  • 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, 2010 at 9:34
  • Johannes: can't believe I forgot about $pwd, thanks!
    – MattB
    May 30, 2010 at 13:48
  • In my case (Windows 10/11), that file did not exist, so I had to create it: C:\Users\{USER}\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.
    – nelson6e65
    Mar 9, 2022 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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