PowerShell_Scripts/base/Get-ScopeDepth.ps1

3 lines
129 B
PowerShell

$local:_scope = 0;
while ($true) { try { Get-Variable -Scope $_scope | Out-Null; $_scope += 1 } catch { return ($_scope - 1) } }