A few months back, dbatools wizard Fred created a prompt that was so awesome, I never had to use Measure-Command
again. It was cool enough that a number of us ended up adopting it, so I figured I’d share.
Performance is important to us so that’s what the prompt is all about. Nothing fancy, just the current working directory and how long the command took to run.
As you can see in the screenshot above, the first time Get-DbaDatabase
runs, it takes 740 ms. This is because we’re caching the database names, login names, and some other auto-populated variables in the background.
When the command runs again, it takes a more reasonable 110ms to complete because it is not performing any caching.
Want this prompt for yourself? Here it is. Just notepad $profile
, paste this in, save and restart your console. Note that you may have to restart ISE twice if you’re using the ISE.
What the heck is DbaTimeSpanPretty
? I asked Fred for a pretty timespan and he created a C# type to make timespans a bit tidier and… pretty 😂
Thanks, Fred, for all the features!
- Chrissy
Hi, Chrissy,
I’m not seeing a link or any code for the custom prompt.
Thanks!
Seth
Hey Seth – sorry about that. It’s an embedded gist, which you can find here:
https://gist.github.com/potatoqualitee/f73eaea0306773cc54a33773aacc5120
Hi Chrissy, my output of GET-DbaDatabase is different from your…Why is that?
Properties like Lastbackups are not included in my output.
Hey Jowee,
If you loaded the SqlServer or SQLPS module first, it will overwrite the settings for the Database “type”. Try from a fresh prompt without loading that module.
Pingback: Powershell Runtime Prompt – Curated SQL
Chrissy, I really like the prompt, but I implemented into ISE and I could no longer open files. Any ideas why?
Hmmm, tried applying it a second time. This time I can open files. Not sure what happened the first time.
Happy to hear it worked! I’ll add that suggestion to the post, that a second restart of the console may be necessary.
Pingback: What’s in your $Profile? – No Column Name
Pingback: What’s In Your Powershell Profile? – Curated SQL
Thanks for the Blog, the Tools and support; very worthwhile and helpful. Avid dbaTools user.
Havent got the fancy DbaTimeSpanPretty so hacked your code a bit.
It’s like
[Fri 14:00:20][1.224s] C:\Users\jonallen\OneDrive\Scripts\PowerShell\ProfileFunctions>
or
[Fri 14:00:31][42.691ms] C:\Users\jonallen\OneDrive\Scripts\PowerShell\ProfileFunctions>
depending on duration of prev command
Just in case anyone wants to take a look it’s at https://gist.github.com/fatherjack/9c005403b2ffcd95ce5c30d1dc5213d6
Very cool, thanks for the share! You should tweet a screenshot too. People love useful prompts!
Pingback: SQL Server Availability Group FailoverDetection Utility PowerShell Function Improvements – Named Instances, Archiving Data, Speed | SQL DBA with A Beard