Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Friday Fun: Tweaking the PowerShell ISE

Posted on February 19, 2016

Today's fun is still PowerShell related, but instead of something in the console, we'll have some fun with the PowerShell ISE. One of the things I love about the PowerShell ISE is that you can customize it and extend it.  My ISE Scripting Geek project is an example.  But today I have a simple example that you can try.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

When I'm training or creating courses for Pluralsight, I am often in the PowerShell ISE and it would be helpful to highlight the line of code I am going to run. But I don't want to muck around with a mouse. So I have created an ISE shortcut to select the current line.

The ISE has an object model that has a root of $psise which is automatically created when you launch the ISE. I won't go into the entire structure now. For our purposes we want to take advantage of this method:

$psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add()

This method takes 3 parameters, the text to display, an action scriptblock and optionally a keyboard shortcut. If you don't want to use a parameter, use $Null in its place. Sometimes I create menu items that don't have keyboard shortcuts so I'll use $Null. But in this case a keyboard shortcut is the primary purpose.

You can use any combination using Ctrl, Alt, or Shift along with function keys (F2) and alphanumeric characters. I'm going to use Ctrl+L because it is unused. If they keyboard shortcut is already used, you'll get an error when you run the command.

I've posted a short script on GitHub to do the job.

Once I run this script, I have a new menu shortcut.

image

If you make a mistake anywhere or want to re-run the command you'll need to open a new PowerShell tab or restart the PowerShell ISE and try again.

I expect at some point I'll incorporate this into the ISE Scripting Geek module, but for now it is separate.  For now, I'll insert the commands into my PowerShell ISE profile script. In the ISE run this command to edit it:

psedit $profile.CurrentUserCurrentHost

If you've never created it you'll get an error message. The ISE profile script will be something like  C:\Users\Jeff\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1.

Enjoy your weekend.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

3 thoughts on “Friday Fun: Tweaking the PowerShell ISE”

  1. Eddie Butt says:
    February 19, 2016 at 1:37 pm

    Your blog feed is broken. Are you aware?

    1. Jeffery Hicks says:
      February 19, 2016 at 2:53 pm

      Thanks for the heads up. That sometimes happens with caching. I’ll clear the cache and see if that solves it.

    2. Jeffery Hicks says:
      February 19, 2016 at 2:55 pm

      I think I see what you mean. Getting warnings from a plugin that apparently is buggy.

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d