Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Current script special variable

Reply
 
Old 03-01-2007   #1 (permalink)
Frank


 
 

Current script special variable

Hi,

Is there a special variable that contains the current running script like
Perl and Bash: $0

If so, can you tell me where this is documented?

Thanks in advance,

Frank


My System SpecsSystem Spec
Old 03-01-2007   #2 (permalink)
Jason Mobarak


 
 

Re: Current script special variable

Frank wrote:
> Hi,
>
> Is there a special variable that contains the current running script like
> Perl and Bash: $0


The $MyInvocation variable should have the information that you want.

PS> echo "`$MyInvocation" > myinv.ps1
PS> .\myinv.ps1

MyCommand : myinv.ps1
ScriptLineNumber : 1
OffsetInLine : -2147483648
ScriptName :
Line : .\myinv.ps1
PositionMessage :
At line:1 char:11
+ .\myinv.ps1 <<<<
InvocationName : .\myinv.ps1
PipelineLength : 1
PipelinePosition : 1

> If so, can you tell me where this is documented?
>
> Thanks in advance,
>
> Frank
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
return variable through script in script VB Script
Script to hide a variable folder VB Script
Set a variable for the current domain PowerShell
Suggestion: New special variable for pipeline enumeration index PowerShell
Manipulating current directory as a variable PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46