Windows Vista Forums

Execute scripts in current scope?

  1. #1


    JeremyG Guest

    Execute scripts in current scope?

    I think i'm missing something big. I'm hoping that the answer is simple, if
    not I'm going to be very dismayed with powershell.

    I want to run scripts that setup my current working environment with
    variables, objects and functions. This way I can start a new power-shell,
    run a script and be at a useful state immediately.

    In the most simplest form, i want to run this "goodbye.ps1" script:
    $x = "Goodbye World"

    Then at the command line, I want to have this effective outcome:

    PS> $x
    PS> ./goodbye.ps1
    PS> $x
    Goodbye World

    Obviously the ability to do this would be awesome. If this is possible I
    can write a script that would create Active Directory objects, pre-set arrays
    or XML files. Then work with them free-form depending on what i need to do.

    Help!

      My System SpecsSystem Spec

  2.   


  3. #2


    Brandon Shell Guest

    Re: Execute scripts in current scope?

    It is easy
    PS> get-help about_scope -full

    "JeremyG" <JeremyG@discussions.microsoft.com> wrote in message
    news:842BF40D-B4AA-4D22-89FF-E4C77269772F@microsoft.com...
    >I think i'm missing something big. I'm hoping that the answer is simple,
    >if
    > not I'm going to be very dismayed with powershell.
    >
    > I want to run scripts that setup my current working environment with
    > variables, objects and functions. This way I can start a new
    > power-shell,
    > run a script and be at a useful state immediately.
    >
    > In the most simplest form, i want to run this "goodbye.ps1" script:
    > $x = "Goodbye World"
    >
    > Then at the command line, I want to have this effective outcome:
    >
    > PS> $x
    > PS> ./goodbye.ps1
    > PS> $x
    > Goodbye World
    >
    > Obviously the ability to do this would be awesome. If this is possible I
    > can write a script that would create Active Directory objects, pre-set
    > arrays
    > or XML files. Then work with them free-form depending on what i need to
    > do.
    >
    > Help!



      My System SpecsSystem Spec

  4. #3


    David Guest

    RE: Execute scripts in current scope?

    You just need to "dot" the script. Put a period in front of the script name
    when executing, similar to the UNIX shells. (space between the period and the
    script name).
    PS>. ./goodbye.ps1

    "JeremyG" wrote:

    > I think i'm missing something big. I'm hoping that the answer is simple, if
    > not I'm going to be very dismayed with powershell.
    >
    > I want to run scripts that setup my current working environment with
    > variables, objects and functions. This way I can start a new power-shell,
    > run a script and be at a useful state immediately.
    >
    > In the most simplest form, i want to run this "goodbye.ps1" script:
    > $x = "Goodbye World"
    >
    > Then at the command line, I want to have this effective outcome:
    >
    > PS> $x
    > PS> ./goodbye.ps1
    > PS> $x
    > Goodbye World
    >
    > Obviously the ability to do this would be awesome. If this is possible I
    > can write a script that would create Active Directory objects, pre-set arrays
    > or XML files. Then work with them free-form depending on what i need to do.
    >
    > Help!


      My System SpecsSystem Spec

  5. #4


    JeremyG Guest

    RE: Execute scripts in current scope?

    Ah ha! Thank you!

    I knew it had to be something simple....for some reason I wasn't getting
    that from any of the docs I was reading. I dont have much of a *nix
    background or I probably would have known right off.

    Now the world is my play thing!

    "David" wrote:

    > You just need to "dot" the script. Put a period in front of the script name
    > when executing, similar to the UNIX shells. (space between the period and the
    > script name).
    > PS>. ./goodbye.ps1
    >
    > "JeremyG" wrote:
    >
    > > I think i'm missing something big. I'm hoping that the answer is simple, if
    > > not I'm going to be very dismayed with powershell.
    > >
    > > I want to run scripts that setup my current working environment with
    > > variables, objects and functions. This way I can start a new power-shell,
    > > run a script and be at a useful state immediately.
    > >
    > > In the most simplest form, i want to run this "goodbye.ps1" script:
    > > $x = "Goodbye World"
    > >
    > > Then at the command line, I want to have this effective outcome:
    > >
    > > PS> $x
    > > PS> ./goodbye.ps1
    > > PS> $x
    > > Goodbye World
    > >
    > > Obviously the ability to do this would be awesome. If this is possible I
    > > can write a script that would create Active Directory objects, pre-set arrays
    > > or XML files. Then work with them free-form depending on what i need to do.
    > >
    > > Help!


      My System SpecsSystem Spec


Execute scripts in current scope?
Similar Threads
Thread Forum
Find my current drive letter and execute a program from it while i VB Script
Scope of objects in scripts PowerShell
How to execute (perl) scripts in Powershell without DOS box PowerShell
Right-click execute scripts ? PowerShell
AD LogOn Scripts Execute permissions Vista account administration