Get-PSCallStack - PowerShell command help and examples

Displays the current call stack. (Get-PSCallStack)


NAME
Get-PSCallStack
SYNOPSIS
Displays the current call stack.
SYNTAX
Get-PSCallStack [<CommonParameters>]
DESCRIPTION
The Get-PSCallStack cmdlet displays the current call stack. Although it is designed to be used with the Windows PowerShell debugger, you can use this cmdlet to display the call stack in a script or function outside of the debugger. To run a Get-PSCallStack command while in the debugger, type "k" or "get-pscallstack".
PARAMETERS
<CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters".
INPUTS
None You cannot pipe objects to this cmdlet.
OUTPUTS
System.Management.Automation.CallStackFrame Get-PSCallStack returns an object that represents the items in the call stack.
NOTES

Examples

EXAMPLE 1
C:\PS>function my-alias { $p = $args[0] get-alias | where {$_.definition -like "*$p"} | ft definition, name -auto } PS C:\ps-test> set-psbreakpoint -command my-alias Command : my-alias Action : Enabled : True HitCount : 0 Id : 0 Script : prompt PS C:\ps-test> my-alias get-content Entering debug mode. Use h or ? for help. Hit Command breakpoint on 'prompt:my-alias' my-alias get-content [DBG]: PS C:\ps-test> s $p = $args[0] DEBUG: Stepped to ': $p = $args[0] ' [DBG]: PS C:\ps-test> s get-alias | Where {$_.Definition -like "*$p*"} | ft Definition, [DBG]: PS C:\ps-test>get-pscallstack Name CommandLineParameters UnboundArguments Location ---- --------------------- ---------------- -------- prompt {} {} prompt my-alias {} {get-content} prompt prompt {} {} prompt [DBG]: PS C:\ps-test> o Definition Name ---------- ---- Get-Content gc Get-Content cat Get-Content type
Description
----------- This command uses the Get-PSCallStack cmdlet to display the call stack for My-Alias, a simple function that gets the aliases for a cmdlet name. The first command enters the function at the Windows PowerShell prompt. The second command uses the Set-PSBreakpoint cmdlet to set a breakpoint on the My-Alias function. The third command uses the My-Alias function to get all of the aliases in the current session for the Get-Content cmdlet. The debugger breaks in at the function call. Two consecutive step-into (s) commands begin executing the function line by line. Then, a Get-PSCallStack command is used to retrieve the call stack. The final command is a Step-Out command (o) that exits the debugger and continues executing the script to completion. RELATED LINKS Online version: http://go.microsoft.com/fwlink/?LinkID=113326 about_Debuggers Set-PSBreakpoint Get-PSBreakpoint Enable-PSBreakpoint Disable-PSBreakpoint Remove-PSBreakpoint C:\Windows>powershell get-help Send-MailMessage -full

Microsoft Windows [Version 10.0.19045.3693]
Copyright (c) 2023 Microsoft Corporation.

ColorConsole [Version 3.7.1000] PowerShell 2.0-Export

Windows 11, 10, 8.1, 8, 7 / Server 2022, 2019, 2016











Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



PowerShell: Displays the current call stack.

HTTP: ... PS_Windows/en/Get-PSCallStack.htm
0.077
12877
I want to digitize my Vinyl records?
Was ist Windows 2011?
Automatisches Beenden oder Standby, wenn AKKU ?? Prozent hat!
Set countdown to shutdown the PC at the specified time!
Fixed time for shutdown or don't sleep timer when the program starts!
Unterschied zwischen dem Internet und WWW?
Unterschied kostenlose Email und vollwertige echte Email (was ist besser)?
Include or exclude in Windows 8 / 8.1 / 10 compressed files when searching for files (. ZIP,. CAB, etc.)!
Windows 10 / 11 search indexing service, customize, disable!
Enable or turn off the mouse pointer shadow in Windows 8.1/10!



(0)