PowerShell Demo Prompt

When I teach I have to set my fonts really big so that folks in the back can see. I show PowerShell from time to time, and people keep asking me about my latest prompt.  Here’s what my prompt looks like:


{ univac\Buck on UNIVAC using AMD64 }

--    12/23/2009 7:54:10 PM    --



There’s a blank line under there, and all my text is green from there on. Having the prompt this way lets me have a long path display without affecting the display of the commands or their output. Here’s how to do that if you want something similar on your own PowerShell display (Don’t do any of this, of course, until you understand these commands and what their affect will be on your own test system, test before you put into production, all rights reserved, don’t run with scissors, never trust scripts, etc.):


You can save the prompt files in your “My Documents” folder by creating a folder underneath called “WindowsPowerShell” if it isn’t there already.


In that, set up a text file called “Microsoft.PowerShell_profile.PS1”. That’s your regular PowerShell prompt. For the SQL Server 2008 PowerShell provider, you can create another file called “Microsoft.SqlServer.Management.PowerShell.sqlps_profile.PS1” with a different (or the same) prompt if you like.


Note that for all these to work, you need to set your execution policy in PowerShell to at least “Remote Signed”, which lets you run scripts. You can set that with this command:

Set-ExecutionPolicy RemoteSigned


Here’s the script that makes it all happen:


# Remember - to run scripts you have to use this command as an admin:

# Set-ExecutionPolicy RemoteSigned


function prompt {   

$cPath = [ConsoleColor]::Red

$cComputerName = [ConsoleColor]::Cyan

$cTime = [ConsoleColor]::DarkCyan

$cCommand = [ConsoleColor]::Green


$host.UI.RawUI.WindowTitle = "PowerShell - $env:computername $pwd" 

   write-host "{"$env:userdomain"\"$env:username" on "$env:computername "using" $env:processor_architecture "}" -f $cComputerName

   write-host "--   " (get-date) "   --" -f $cTime

   write-host ($pwd) -f $cPath

   return ' '


Skip to main content