How to Configure a PowerShell ISE Theme and User Profile

Although I’ve been using PowerGUI to write PowerShell and PowerCLI code for many years, I’ve migrated to PowerShell’s Integrated Scripting Environment (ISE). There’s a few reasons for this:

  1. PowerShell ISE is included with Windows by default, reducing the amount of software I have to deal with.
  2. PowerGUI is bulky and getting long in the tooth.
  3. I don’t use the Administrative Console or PowerPack addons to write scripts.
  4. Iterative updates to PowerShell ISE are focused on new features provided with PowerShell 5.0 and Desired State Configuration (DSC).

I get that everyone has their personal preferences on tools. If you like PowerGUI, stick with it. If you’re curious about PowerShell ISE, I’ll go deeper into how I use it below.

Select a Theme

The first thing I suggest doing is setting up the color theme for productive coding. The default theme is “Dark Console, Light Editor” which is pleasant enough for starting off, but I prefer the “Dark Console, Dark Editor” theme to give code greater contrast and also emulate the natural PowerShell CLI. To make this change, navigate to Tools > Options > Colors and Fonts > Manage Themes. This is also where you can tweak other colors if desired, but the font coloring is pretty decent out of the box.

powershell-options-color-dark

While you’re here, you can also toggle over to the General Settings tab to adjust the AutoSave interval. It’s set to 2 minutes by default, which I find to be enough to keep me honest, but you can adjust it up or down to suit your taste.

If you want to get fancier, I’ve actually taken a shine to the Oblivion theme on the Eclipse Color Themes website. While not usable in its native form, the XML file can be converted to a PowerShell ISE theme using a converter provided by akawhoami on GitHub.

ect-to-ise-converter

To load an XML color theme, head back over to the PowerShell ISE Theme Manager from my earlier example and choose to import a theme file. Oddly enough, there’s no simple “import my theme” cmdlet. You can set the colors once per workstation, bake in the specific color options in your profile, or use someone’s third party scripts. I don’t mind doing it manually, or perhaps a reader will show me a better way. :-)

Presenting Code

If you’re going to present code on a projector screen, I’d go back to a light background with dark text. Because most projector screens are a white screen, it’s not possible to make the background color truly dark – the projector simply projects “nothing” for black and you end up getting a funky washed out look.

Build a User Profile

A profile is a script that is called when PowerShell or PowerShell ISE opens. Profile information can live in two locations:

Current User: %USERPROFILE%\Documents\WindowsPowerShell\
All Users: %WINDIR%\System32\WindowsPowerShell\v1.0\

Additionally, there are three types of profile files:

ISE and Console: profile.ps1
ISE only: Microsoft.PowerShellISE_profile.ps1
Console only: Microsoft.PowerShell_profile.ps1

Seems a tad overkill. I personally select the current user path and drop in a profile.ps1, then just check for the $psISE variable to determine if the host is running the ISE. Here’s the path where it sits:

C:\Users\Chris.GLACIER\Documents\WindowsPowerShell\profile.ps1

My profile file is short and sweet, including a fun little message to myself for when I launch the ISE:

Set-ExecutionPolicy Bypass
Set-Location C:\Dropbox\Code
if ($psISE)
{
Start-Steroids
Clear-Host
Write-Host 'BEAST MODE (╯°□°)╯︵ ┻━┻'
}

This is a very simple profile. Here’s what it does:

  1. Make sure the execution policy is effectively disabled (requires Running as Administrator)
  2. Set the console location to my Dropbox\Code folder, because that’s where I work on PowerShell code in most cases.
  3. Test to see if the $psISE variable exists, meaning that I’m launching the ISE. If it does, I start ISESteroids and pump myself up with a little table throwing action.
    • If I’m in the console, the logic test fails and nothing else happens.

Here’s what a fresh ISE session looks like when loaded up:

launch-ise

The PowerShell console is simpler.

launch-console

Run as Administrator

I run both the ISE and Console as Administrator by changing the shortcut. This avoids issues with the execution policy and gives me unfettered authority over the scripting editor. Nothing more annoying than running into errors due to permissions on my own computer. :)

To do so, find the shortcut for PowerShell or PowerShell ISE, open the Properties > Shortcut > Advanced > and check the Run as administrator box.

run-as-admin-ise

Thoughts

At this point I have what I consider to be a usable copy of PowerShell ISE at my disposal. While it may look like a lot has happened, it isn’t that much and only happens on a new system. I have a master copy of the profile, colors, and portable modules that I clone to my workstations via Dropbox. I’m also a huge fan of ISESteroids, which I plan to go over in greater depth in the future.