Turning ISE into a Custom PowerShell Console

by Apr 8, 2013

A lot of products come with their own PowerShell consoles. There are special PowerShell consoles for Exchange, for SQL Server, for Active Directory, you name it.

In reality, all of these legacy PowerShell consoles are just plain vanilla PowerShell consoles that auto-load command libraries and optionally set up additional things.

So if you'd like to use the many new features found in PowerShell ISE 3.0 (like rich IntelliSense, etc.), you can use ISE instead of those custom PowerShell consoles. All you need to do is find out what these consoles did to initialize.

To do that, you can examine the shortcut you use to launch those custom PowerShell consoles. When you look at the shortcut properties, often you find that the shortcut really just calls powershell.exe and specifies a launch script that does the initialization.

Once you identified the initialization script, you can run this launch script just as easily in your ISE editor to add the very same commands. Just make sure you run the script dot-sourced (place a dot and a space before the script path). Else, the script would run but immediately discard all the changes again.

Another approach is to use Get-Module and Get-PSSnapin to check which modules and snap-ins were loaded by the custom PowerShell. Then, you can compare the results to a regular PowerShell and manually load all missing command libraries using Import-Module and Add-PSSnapin.

Note however that loading command libraries usually is just one of two steps. Many custom PowerShell consoles call initialization commands, for example to connect to a specific instance of Exchange.

Technically speaking, ISE can be a complete replacement for any custom PowerShell console, and it can even combine the specific commands from multiple custom PowerShell consoles so you have a "one stop serves all" solution. It just takes a bit of experimenting to find out the specific customization work done by a custom PowerShell console.

Twitter This Tip! ReTweet this Tip!