Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
It started with a simple question: is there a shortcut to go to the Console Pane in the ISE? A few web pages gave lists of shortcuts, but then this guy went the extra … parsec.
TL;DR: He scraped Microsoft.PowerShell.GPowerShell DLL for strings.
That left him with a [hashtable] of name/value pairs. I wanted something a little slicker, so I added a bit of output processing to turn it into a .CSV.
$OutputPath = "$home\Desktop\PshIseKeyboardShortcuts.csv"
$ErrorActionPreference = 'stop'
if (!$psISE)
{
Write-Error "This must be run inside PowerShell_ise.exe";
}
trap
{
if ($DebugPreference -eq 'continue')
{
Write-Host -ForegroundColor Red $_.Exception.Message; $Host.EnterNestedPrompt();
}
}
$OutputFolder = Split-Path -Path $OutputPath -Parent
if (!(Test-Path -Path $OutputFolder))
{
New-Item -Path $OutputFolder -ItemType Directory | Out-Null
}
if (Test-Path -Path $OutputPath)
{
Remove-Item -Path $OutputPath
}
# https://www.powershellmagazine.com/2013/01/29/the-complete-list-of-powershell-ise-3-0-keyboard-shortcuts/
# All shortcuts are contained in the ISE Microsoft.PowerShell.GPowerShell assembly (DLL).
# We first need to get a reference to that DLL.
$assemblyReference = $psISE.GetType().Assembly
# Next we create a ResourceManager object which provides access to the assembly resources.
# We pass it the name of the resource we want to access without the .resources extension,
#and the assembly containing the resources.
$resourceManager = New-Object System.Resources.ResourceManager GuiStrings, $assemblyReference
# All that’s left is calling the GetResourceSet() method to retrieve the resource set for a particular culture.
$resourceSet = $resourceManager.GetResourceSet((Get-Culture),$true,$true)
# Looking at the output we can see that the highlighted items value resembles key combinations.
# If you look at your output you will notice items with a name that ends with ‘Shortcut’ (with
# or without a trailing digit) and items that relates to Function keys. They start with F,
# followed by a digit or two and the word ‘Keyboard’. With the following line we can filter
# all keyboard related items and sort them out.
$shortcuts = $resourceSet |
? { ($_.Name -match 'Shortcut\d?$|^F\d+Keyboard') -and ($_.Name -notmatch 'KeyboardDisplayName') } |
Select-Object -Property @{
n = 'Shortcut';
e = {
$_.value -replace '\+', ' + ';
}
}, @{
n = 'Meaning';
e = {
$_.key -creplace "([A-Z])", " `$1" -creplace '([^F\d])(\d+)', "`$1 `$2"
}
} | Sort-Object -Property ShortCut |
Export-Csv -NoTypeInformation -Path $OutputPath
ii $OutputPath
Please sign in to use this experience.
Sign in