Displays the current call stack. (Get-PSCallStack)



Displays the current call stack.

Get-PSCallStack [<CommonParameters>]

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".

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

You cannot pipe objects to this cmdlet.

Get-PSCallStack returns an object that represents the items in the call stack.



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.

Online version: http://go.microsoft.com/fwlink/?LinkID=113326

C:\Windows>powershell get-help Send-MailMessage -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows-10 / Windows-8.1 & 8 / Windows-7 & Vista / Windows Server 2008-2016
»»»» ColorConsole


... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell


Download the Windows 10 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
Windows 8 Upgrade von Windows 7, Vista, XP, geht das Updaten?  / Has Q-Dir a single tree that can be used for all panes?  / Wie lange dauert es, bis Windows 10 installiert ist (Download)?  / Help in Windows 8 is missing the old Start menu, how can i activate it?  / I have problems with Aero in Windows 7, how to fix and activate it?  / Warum bewertet Windows 7 meinen PC mit einem Leistungsindex?  / Was ist der Windows Kompatibilitätsmodus?  / Automatisches Ausklappen der Windows-System-Favoriten bei Programmstart in Q-Dir.  / Starten des Geräte-Managers unter Windows 8, 8.1 und Win 10 (öffnen, finden)!  / Wo finde ich die Einstellungen auf Samsung Galaxy?  / Customize the paging file pagefile.sys in Windows 8.1, 8 and 10!  / Access to hidden options in Windows Explorer, via mouse!  /