November 13th, 2018

PowerShell PowerTip: Customizing your prompt

Kory Thacher
Premier Field Engineer
I’ve been taking a break from the blog for a while due to some personal reasons, but I had a few people ask me about my PowerShell prompt recently.
I like extra horizontal space, so I removed the path from the prompt and put it in the window title bar. I also just display the current time in the prompt itself.
You can customize your prompt by using your profile and overriding the “Prompt” function.
A coworker of mine, Tony Radkiewicz, used a similar prompt and I really liked it so I’ve been using it since.
function prompt 
{
$Time = (Get-Date).ToString("hh:mm") 
$host.ui.rawui.WindowTitle = (Get-Location)
"$Time> "
}
That’s all for now, I’ll try to get some more tips out as I have time!

Author

Kory Thacher
Premier Field Engineer

I've been a PFE since 2012, working with various technologies. I live in the modern applications domain, doing work in UWP apps, .NET, Unity, DevOps, and of course PowerShell. I've been teaching PowerShell related workshops very frequently for years, and I really enjoy getting the opportunity to explain a topic or learn something new from my colleagues. I enjoy scripting because of how fast and interactive it can be, and I love getting interesting problems to work on with customers. ...

More about author

0 comments

Discussion are closed.