Set-PSBreakpoint -Variable idx -Mode Write -Action { Write-Host -ForegroundColor Red "MyAction: $($idx)" } Function Test ($p) { 0..$p | % { $idx = $_ $idx } } Test 3
您可以使用$MyInvocation,例如:
Set-PSBreakpoint -Variable idx -Mode Write -Action { Write-Host -ForegroundColor Red "$($MyInvocation.MyCommand.Name): $($idx)" }