Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

$myInvocation.ScriptLineNumber not working as I would expect

$
0
0

Hello

If I have a simple script like so

# test
get-process
$myInvocation.ScriptLineNumber

 

I would expect the lat line of output to return 3 (as on line 3). However it returns 1 not matter where a script I put this command e.g. line 1021 still returns 1

for various reasons I would like to output the line number at a number of points therefore thought the above would do the trick.

Andy advice please how the achieve this and why does the above not work

 

Thanks All

AAnotherUser__

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles