Automatically Customizing the PowerShell ISE on Startup

This past weekend while at SQL Saturday Chattanooga, I was asked if it was possible to have the PowerShell ISE (Integrated Scripting Environment) automatically open with a right/left split pane:

Instead of the top/bottom default split pane:

One thing to note is that by default the PowerShell ISE will reopen in whatever configuration you close it in, which could be either of the ones previously shown or the full screen editor.

If you want the ISE to open with a certain configuration no matter what it was when it was closed, you can set it using one of the two profiles that only apply to the ISE. In this scenario, I’ve chosen to use the all users ISE profile since I log into my computer as a different user than I run PowerShell as and I’m the only person who uses my computer.

Showing the right/left split pane with code is simple enough:

That code just needs to be added to one of the PowerShell profiles that only applies to the ISE. You can view the locations for the different profiles that apply to the ISE by running the following code from within the ISE:

I wanted to make sure the following code would work properly no matter what host it was run from, so I decided to specify the location itself and store it in a variable.

I check to see if the profile already exist and create it if it doesn’t. Then add the previously shown code to the profile to make it always open with the right/left split pane configuration.

The value from the following variable could be used instead of the one I created in the previous example if the code to add the entry is being run from the PowerShell ISE:

I could use something like the following code to make sure it’s only run from within the ISE and to only add the entry if it doesn’t already exist:

One thing I have in the profile that I personally use is code that sets the zoom to 100% since I often present sessions where I set the zoom level much higher and I want it set back to the default when I close and reopen the ISE.

I use three profiles for applying different settings to specific host and/or all hosts. My profiles can be found in my PowerShell repository on GitHub.

There are 6 possible profiles within PowerShell by default and a certain precedence for them as demonstrated in a previous blog article I’ve written: “PowerShell $Profile: The six options and their precedence“.

µ

1 Comment

  1. jefferyhayesblog

    Why can’t I put the scripting on the left and the console on the right?

    Reply

Leave a Reply

%d bloggers like this: