Created
February 28, 2019 18:15
-
-
Save PrateekKumarSingh/9100d8115b39dd39818b69caf227cd57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Vars{ | |
Write-Host "-------------------------------------------------------------------" | |
Write-Host "-------------------------------------------------------------------" | |
switch($host.Name){ | |
'Visual Studio Code Host' { | |
$psEditor.GetEditorContext().CurrentFile.tokens.where({$_.kind -eq 'variable'}) | Select @{n='Name';e={$_.extent}},@{n='value';e={iex $($_.extent)}} -Unique | |
} | |
'Windows PowerShell ISE Host' { | |
$abstractSyntaxTree = [System.Management.Automation.Language.Parser]::ParseInput($psISE.CurrentFile.Editor.Text, [ref]$null, [ref]$null) | |
$AbstractSyntaxTree.FindAll({$args[0] -is [System.Management.Automation.Language.VariableExpressionAst ]}, $true) | Select @{n='Name';e={$_.extent}},@{n='value';e={iex $($_.extent)}} -Unique | ft -AutoSize | |
} | |
} | |
Write-Host "-------------------------------------------------------------------" | |
Write-Host "-------------------------------------------------------------------" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment