Search

v3 - $MyInvocation.ScriptName or MyCommand Blank Inside ForEach-Object Loops by JakFrost

Active

1
1
Sign in
to vote
Type: Bug
ID: 772063
Opened: 11/23/2012 12:25:03 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
$MyInvocation is now foobared after upgrade to 3.0 inside ForEach-Object loops and it's missing the $MyInvocation.MyCommand.Name property that used to refer to the name of the script.

Coincidentally the $MyInvocation.ScriptName property is now foobared in the main script scope and shows blank.

So both of these properties that should show the name of the script are exclusively farked up.
Details (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

No, this is new to the most recent version
Reproduction Steps
$MyInvocation |
Select-Object -Property MyCommand, ScriptName |
Format-List -Property *

ForEach-Object {
    $MyInvocation |
    Select-Object -Property MyCommand, ScriptName |
    Format-List -Property *
}

MyCommand : Test.ps1
ScriptName :

MyCommand :
ScriptName : C:\Test.ps1
Expected Results
MyCommand :
ScriptName : C:\Test.ps1

MyCommand :
ScriptName : C:\Test.ps1
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.