Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codykonior/4f0c5cc36b34119a3f7ce61ebb69f08f to your computer and use it in GitHub Desktop.
Save codykonior/4f0c5cc36b34119a3f7ce61ebb69f08f to your computer and use it in GitHub Desktop.
CallStack printing
$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