wolfgang ziegler


„make stuff and blog about it“

Windows PowerShell ISE Keyboard Shortcuts

April 2, 2013

If you are new to PowerShell and want to get started quickly, take a look at this handy cheat sheet.

Experienced users of Windows PowerShell among you will probably know and already have worked with PowerShell ISE (Integrated Scripting Environment). PowerShell ISE is a lightweight but very useful IDE which I am using quite often for developing, maintaining and try-running my PowerShell scripts

Whenever I work with a tool on a regular basis I try to learn and use its keyboard shortcuts to be more productive and efficient. That’s why I was really excited when I found out that there was a way of programmatically retrieving all the available keyboard shortcuts in PowerShell ISE.

I discovered this nice little trick on the website Powershell.com which offers a PowerTip of the Day service, providing useful tips or code snippets around PowerShell or the PowerShell ISE.

Lately this PowerTip of the Day offered a code snippet which extracts all the built-in keyboard shortcuts of the PowerShell ISE and displays them in a table. Here is the few lines of PowerShell code for that:

$gps = $psISE.GetType().Assembly

$rm = New-Object System.Resources.ResourceManager GuiStrings, $gps

$rs = $rm.GetResourceSet((Get-Culture), $true, $true)

$rs | where Name -match 'Shortcut\d?$|^F\d+Keyboard' |

  Sort-Object Value |

  Format-TableAutoSize

 

By modifying this script slightly and using the Out-GridView command instead of Format-Table for displaying the data get an even nicer result:

 

$gps = $psISE.GetType().Assembly

$rm = New-Object System.Resources.ResourceManager GuiStrings, $gps

$rs = $rm.GetResourceSet((Get-Culture), $true, $true)

$rs | where Name -match 'Shortcut\d?$|^F\d+Keyboard' |

  Sort-Object Value |

  Out-GridView

 

 

image1

Now we have a fully interactive list view containing all available shortcuts in PowerShell ISE. This makes exploring these shortcuts even easier by being able to sort and filter them using the built-in functionality of the Out-GridView command.

image2

 

This Power Tip of the Day is a really clever example demonstrating the invaluable advantage we get by just thinking a little bit outside the box. Instead of treating the PowerShell ISE just as a simple tool for creating and maintaining scripts, it becomes a source of information of its own.

Solving small challenges and issues like that is what makes us more productive and efficient in the long run.