Windows Vista Forums

Retaining variables after script execution

  1. #1


    Tim Munro Guest

    Retaining variables after script execution

    Hi all,

    While sitting at a powershell command prompt, is there a way to
    execute a script and retain all the variables the script used after
    execution is complete?

    Thanks.
    --
    Tim.



      My System SpecsSystem Spec

  2. #2


    George Davis Guest

    RE: Retaining variables after script execution

    Tim,
    You can make variables global in scope during script execution. So if you
    have the following line in your script:

    $GLOBAL:someVar = "Hello"

    Even if that variable doesn't exist before you run the script, it will after.

    --George


    "Tim Munro" wrote:

    > Hi all,
    >
    > While sitting at a powershell command prompt, is there a way to
    > execute a script and retain all the variables the script used after
    > execution is complete?
    >
    > Thanks.
    > --
    > Tim.
    >
    >
    >

      My System SpecsSystem Spec

  3. #3


    Tim Munro Guest

    Re: Retaining variables after script execution

    George, thatnks for your input. I'm looking for something that will let me
    see the final state of things after a scruipt runs. To scope everything as
    Global for debugging and then having to remove it all when all is working
    just doesn't seem like the right way to do things.

    --
    Tim

    "George Davis" <GeorgeDavis@xxxxxx> wrote in message
    news:40511FD2-38B1-444B-9127-35D1CA231CF3@xxxxxx

    > Tim,
    > You can make variables global in scope during script execution. So if you
    > have the following line in your script:
    >
    > $GLOBAL:someVar = "Hello"
    >
    > Even if that variable doesn't exist before you run the script, it will
    > after.
    >
    > --George
    >
    >
    > "Tim Munro" wrote:
    >

    >> Hi all,
    >>
    >> While sitting at a powershell command prompt, is there a way to
    >> execute a script and retain all the variables the script used after
    >> execution is complete?
    >>
    >> Thanks.
    >> --
    >> Tim.
    >>
    >>
    >>


      My System SpecsSystem Spec

Retaining variables after script execution

Similar Threads
Thread Forum
paaing variables from script to plink cmd
Hi I've been working on a script that takes information from a HTA screen and then uses them as variables to run a plink command. The user input...
VB Script
Include another script, keep variables in included script?
I want to run or include a PS script from within another PS script. But want the values set in the 2nd one to be available in the first one. For...
PowerShell
Need help with PHP Script variables
Hey, I am trying to write a script for my website which will allow me to be able to say, Hello (computer username), You IP is (ip). With the...
Network & Sharing
Pop-up to enter variables to pass to script
Hi, I'd like to know how I create a pop-up, using .net, to populate it with variables that would be passed to my powershell script... thanks,
PowerShell
Passing variables to script
Hi, Can someone please tell me how I pass variables to a powershell script... thanks,
PowerShell
Terminate Script Execution?
I am trying to use ctrl+c to terminate a script but nothing happens. So far I have only been able to close the command shell in order to get a...
PowerShell
How To: Create Global Variables within a function or Script
Goal: ----- I have numerous list of servers that pass down the pipe. Instead of having to create the server group manually, I want to write a...
PowerShell