ISE Addons, PowerShell, ShowUI, WPF
comments 2

PowerShell ISE addon menu generator – The ShowUI way

Update: @Jaykul was kind enough to review this code and post an updated (and better) version of this addon with guidelines & best practices. Don’t forget to read the first few lines of text on that page to learn the best practices when scripting WPF UI.

A while ago, I wrote about a PowerShell ISE addon that can be used to add items to ISE and load them dynamically by adding the same to ISE profile. This used WinForms to generate the GUI required for the addon functionality. As you may know already, ShowUI 1.1 is available for creating WPF UI in PowerShell. So, I decided to re-write this addon to use ShowUI. Here is the new code:

The WinForms implementation of this addon had 235 lines of PowerShell code. Where as, ShowUI version has only 48 lines! This shows that the value per line of PowerShell code is amazing when using ShowUI. ShowUI really makes it easy. Thanks to James Brundage and Joel Bennett.

Now, to use this addon:

  1. Copy the contents of above script to a .ps1 file
  2. Dot source this .ps1 in your profile script for ISE
  3. Add the following code to the next line:

This is it. So, every time you press ALT+M in PowerShell ISE, it brings up a simple dialog to add a new menu item. Take a look at the below screenshot to see how I am adding an option to get a list of processes with larger working set.

Addon in ShowUI

Addon in ShowUI

So, any time I press Ctrl+Alt+P, I get a list of top of 5 processes in a grid view. Simple!

Filed under: ISE Addons, PowerShell, ShowUI, WPF

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.