tags:

views:

13

answers:

1
Set-PSBreakpoint -Variable idx -Mode Write -Action { 
    Write-Host -ForegroundColor Red "MyAction: $($idx)"
}

Function Test ($p) {

    0..$p | % {
        $idx = $_
        $idx
    }
}

Test 3
+3  A: 

You can use $MyInvocation e.g.:

Set-PSBreakpoint -Variable idx -Mode Write -Action {  
    Write-Host -ForegroundColor Red "$($MyInvocation.MyCommand.Name): $($idx)" 
} 
Keith Hill
Thanks Keith. I tried $MyInvocation.ScriptNamem and of course it didn't work.
Doug Finke