Created
July 19, 2019 13:45
-
-
Save codykonior/4f0c5cc36b34119a3f7ce61ebb69f08f to your computer and use it in GitHub Desktop.
CallStack printing
This file contains 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
$previousCallStack = $null | |
$callStackPath = Get-PSCallStack | Where-Object { $_.Command -ne "<ScriptBlock>" } | ForEach-Object { | |
if (-not $previousCallStack -or $_.InvocationInfo.Line -ne $previousCallStack.InvocationInfo.Line -or $_.InvocationInfo.PipelineLength -ne $previousCallStack.InvocationInfo.PipelineLength -or $_.InvocationInfo.PipelinePosition -ne ($previousCallStack.InvocationInfo.PipelinePosition - 1)) { | |
$previousCallStack = $_ | |
$_ | |
} | |
} | Group-Object Command | Select-Object -ExpandProperty Name | |
$callStackPath = ("> " + ($callStackPath -join "> ")).Trim() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment