1.    29 Jun 2007 #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.    29 Jun 2007 #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

  3.    29 Jun 2007 #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

  4.    29 Jun 2007 #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


Similar Threads
Thread Forum
Find my current drive letter and execute a program from it while i
HI! The problem is that when i change the directory to usbletter:\SYSTEM i can't find a way to execute a program from the source directory where...
VB Script
Scope of objects in scripts
I am trying to modify a script (http://www.terminal23.net/2007/04/powershell_auditing_permissions.html) to create an array of custom objects prior...
PowerShell
Execute PowerShell Scripts via http url requests
Is there a way to execute PowerShells commands/scripts via http url requests? An example would be something like:...
PowerShell
How to execute (perl) scripts in Powershell without DOS box
Hi folks, I am trying to execute a bunch of perl scripts from within a Powershell by simply writing their name (and pressing Return, of course)....
PowerShell
Executing scripts in the current directory
I guess I've casually accepted that in Monad ... then PowerShell ... that I can't execute a script by typing: ScriptName or ScriptName.ps1...
PowerShell
Right-click execute scripts ?
Hi, have installed PowerShell How can I have scripts auoexecute whith a right-click->execute action ( as can be achieved with others scripts)...
PowerShell
AD LogOn Scripts Execute permissions
Testing Environmet: Ms Virtual Server 2k5 R2 Testing Environment Host OS: Enterprise Server 2k3 x64 Edition Testing Environment Hardware: Intel...
Vista account administration

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 13:11.
    .