Created
November 5, 2015 23:15
-
-
Save jeffgreenca/c1c84d9577ad301ee017 to your computer and use it in GitHub Desktop.
Recursive variable dump, appropriate for crawling VMware PowerCLI Get-View objects
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 vd($v, $p) { | |
if($v -eq $null) { | |
echo "[$p] -> null" | |
} else { | |
$v | gm -MemberType Property | % { | |
if ($_.Definition.ToString() -match "\[\]") { | |
for($i = 0; $i -lt $v.$($_.name).length; $i++) { | |
vd $v.$($_.name)[$i] "$p.$($_.name)[$i]" | |
} | |
} elseif ($_.Definition -cmatch "(^System)|(^[a-z])") { | |
echo "[$p.$($_.name)] -> $($v.$($_.name))" | |
} else { | |
vd $v.$($_.name) ($p + "." + $_.name) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment