How to Get the Current Function Name in PowerShell
To get the current function name in PowerShell, read $MyInvocation.MyCommand.Name inside the function. It returns the name of the command that’s running right now: I’ll also cover script blocks, the caller’s name, aliases, script paths, logging, and two PowerShell 7 vs 5.1 differences. Get the current function name with $MyInvocation.MyCommand.Name $MyInvocation is an automatic variable … Read more