My PowerShell profile

We all like to customize our PowerShell profile to our own needs, so there is no right or wrong in how to do this, but I’d like to show you mine nonetheless.

UPDATE: Kirk Munro (@Poshoholic) was good enough to point out that I had a bug in my path shortener, so in the process of rewriting it, I decided to do a small overhaul of my entire PowerShell Profile.

I start by saving the original PowerShell prompt. I then define my new custom prompt, as well as a third demo prompt. I created a short function (Set-Prompt) that I can use to change my prompt on the fly with the prompts I have predefined in my profile.

Next I have my new and improved path shortener, that now also works when using PowerShell providers like registry, variable etc.

I have also created a function that lets me open files for editing in Sublime Text, as well as an extension function of Get-Location (that I later use when overriding the pwd alias further down).

I also converted my old code to check if the current user is running as admin to a function instead.

Next are my alias definitions, followed by setting the new prompt, my custom location and updating my environment variables.

Lastly I load my modules. I have included a check for ISE so that I can use the same profile for both ISE and the normal host.

That’s it. Any comments and suggestions are always welcome!

2 comments

  1. My profile looks alot like Ed Wilson’s. I copied his years ago, but I like what you’re doing with yours as well. I plan on stealing some of your ideas too, after I take a nap.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s