What’s in your $Profile?

Don’t be afraid.
Show me what you got!

Words: 332

Time to read: ~ 1.5 minutes

What’s the Problem?

Recently I came upon a question online that went along the lines of…

Every time I open PowerShell it takes a while to get to the prompt…

Followed by a screenshot along the lines of…

ProfileLoading
The hint is in the pic if you read it

What’s the Cause?

Straight away the online community exploded with a multitude of answers but all sharing  same word $Profile.

Now people use their $profile for different things, from setting up commonly used aliases, to changing the settings of your PowerShell window, and everything in between.

Personally part of my profile is to change the default colour of error message since I’m slightly red-green colour-blind and it’s just too hard to read the default red on blue.

MyProfile
Error and Warning, just to be safe

What about none?

If you don’t want to have a $profile then don’t worry.

By default the $profile variable exists but that doesn’t mean that the file does. You can test this by running


Test-Path $profile

And if that returns a True then you have a profile set up.

You can see what’s in your profile by running the following


notepad $profile

If you don’t want to run a profile, then you can just clear it out.

Or you can start up a PowerShell.exe without a profile by specifying -noprofile

What about yours?

This brings me back to the main point. My profile does 3 things

  1. Changes the default colour of error and warning messages,
  2. Sets an alias for notepad to “n” since I use it so much Set-Alias -Name n -Value notepad , and
  3. loads up the dbatools prompt

I don’t import any modules because the two that I use the most are updated so frequently plus I’m currently using PowerShell 5 so they get automatically loaded when I type in one of their commands.

What’s on your one? Anything special or cool that you’d like to share? Let me know?

Author: Shane O'Neill

DBA, T-SQL and PowerShell admirer, Food, Coffee, Whiskey (not necessarily in that order)...

5 thoughts on “What’s in your $Profile?”

  1. I customized the prompt for normal use and elevated use. Several functions that I have used over the years are loaded in my prompt. Silly things like quote of the day and Christmas countdown timer functions have been in my profile since I started using PowerShell. I then have additional things loading in my VSCode specific profile.

    1. Nice! Apart from the Christmas countdown (I’m a bit of a Grinch so I only like Christmas dinner 🙂 )
      That’s a good point about the VSCode profile, I have a weird one in there that gets a random greeting and uses Sapi.SpVoice to play it. Found it on PowerShell tip of the day a while back. Still get a chuckle out of it

      1. Thanks for the post.
        Yeah adding those personal touches makes it human. I also have functions that perform things like testing ports. I also have a function that when called will store and use my admin credentials. Users should understand… profile.ps1 will run in all powershell sessions… then there are profiles for each hosted session (CLI, ISE, VSCode, PowerShell Studio, etc.)

        1. and of course in your ISE specific profile…
          Enable-ScriptBrowser
          Enable-ScriptAnalyzer
          and for the vscode specific profile…
          Import-Module EditorServicesCommandSuite
          Import-EditorCommand -Module EditorServicesCommandSuite

Leave a Reply

Discover more from No Column Name

Subscribe now to keep reading and get access to the full archive.

Continue reading