Windows Vista Forums

How to retrieve the script name inside Powershell?

  1. #1


    Ben Guest

    How to retrieve the script name inside Powershell?


    $args contains the passing arguements, but no script name. How to get the
    script name inside itself in Powershell?

    Thanks!

      My System SpecsSystem Spec

  2. #2


    Marco Shaw [MVP] Guest

    Re: How to retrieve the script name inside Powershell?

    Inside the script, try:
    $MyInvocation.InvocationName

    "Ben" <Ben@newsgroup> wrote in message
    news:2DF1594D-CDF6-4A43-A2A5-B52B116CA6BA@newsgroup

    >
    > $args contains the passing arguements, but no script name. How to get the
    > script name inside itself in Powershell?
    >
    > Thanks!

      My System SpecsSystem Spec

  3. #3


    Martin Zugec Guest

    Re: How to retrieve the script name inside Powershell?

    Hi Ben,

    have a look at $MyInvocation variable (ScriptName).

    Martin

    "Ben" <Ben@newsgroup> wrote in message
    news:2DF1594D-CDF6-4A43-A2A5-B52B116CA6BA@newsgroup

    >
    > $args contains the passing arguements, but no script name. How to get the
    > script name inside itself in Powershell?
    >
    > Thanks!

      My System SpecsSystem Spec


How to retrieve the script name inside Powershell?
Similar Threads
Thread Forum
Script to read information inside a pdf file VB Script
Can PowerShell retrieve AD "Member Of' information? PowerShell
How can I resolve %WINDIR% inside a PowerShell script? PowerShell
Script to retrieve file versions VB Script
a powershell window inside visual studio? PowerShell