Improve list-automatic-variables.ps1

This commit is contained in:
Markus Fleschutz 2021-05-13 12:07:16 +02:00
parent 1451ad4c69
commit c68ba3d764

View File

@ -6,7 +6,7 @@
#> #>
function AddItem { param([string]$Variable, [string]$Content) function AddItem { param([string]$Variable, [string]$Content)
New-Object PSObject -Property @{ 'Variable' = "$Variable"; 'Content' = "$Content" } new-object PSObject -property @{ 'Variable' = "$Variable"; 'Content' = "$Content" }
} }
function ListAutomaticVariables { function ListAutomaticVariables {
@ -62,10 +62,7 @@ function ListAutomaticVariables {
} }
try { try {
$Vars = ListAutomaticVariables ListAutomaticVariables | format-table -property Variable,Content
$Vars | format-table -property Variable,Content
write-host -foregroundColor green "OK - $($Vars.Count) PowerShell automatic variables total"
exit 0 exit 0
} catch { } catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"