our prompt

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

14 thoughts on “our prompt

  1. Seth Reply

    Hi, Chrissy,

    I’m not seeing a link or any code for the custom prompt.

    Thanks!

    Seth

  2. Jowee12 Reply

    Hi Chrissy, my output of GET-DbaDatabase is different from your…Why is that?
    Properties like Lastbackups are not included in my output.

    • Chrissy LeMaire Post authorReply

      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.

  3. Pingback: Powershell Runtime Prompt – Curated SQL

  4. Tim Cartwright Reply

    Chrissy, I really like the prompt, but I implemented into ISE and I could no longer open files. Any ideas why?

  5. Tim Cartwright Reply

    Hmmm, tried applying it a second time. This time I can open files. Not sure what happened the first time.

  6. Pingback: What’s in your $Profile? – No Column Name

  7. Pingback: What’s In Your Powershell Profile? – Curated SQL

  8. RandyH Reply

    Thanks for the Blog, the Tools and support; very worthwhile and helpful. Avid dbaTools user.

  9. Pingback: SQL Server Availability Group FailoverDetection Utility PowerShell Function Improvements – Named Instances, Archiving Data, Speed | SQL DBA with A Beard

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.