Adding "List All Variables" to PowerShell ISE

by Jun 25, 2015

In a previous tip we showed a script that would find all variable names in all scripts open in PowerShell ISE.

Here is an adaption that adds a new command called "List Variables" to the Add-ons menu inside the PowerShell ISE:

$code = { $psise.CurrentPowerShellTab.Files | ForEach-Object { $errors = $null [System.Management.Automation.PSParser]::Tokenize($_.Editor.Text, [ref]$errors) | Where-Object { $_.Type -eq 'Variable'} | Select-Object -Property Content | Add-Member -MemberType NoteProperty -Name Script -Value $_.DisplayName -PassThru } | Sort-Object -Property Content, Script -Unique | Out-GridView -Title 'Variables in use' -PassThru } $psise.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('List Variables', $code, 'ALT+V') 

Once you ran this code, you can press ALT+V to open a grid view window with all currently used variables inside all open scripts.

Twitter This Tip! ReTweet this Tip!