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 - Retaining variables after script execution

Reply
 
Old 11-21-2008   #1 (permalink)
Tim Munro


 
 

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
Old 11-21-2008   #2 (permalink)
George Davis


 
 

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:
Quote:

> 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
Old 11-25-2008   #3 (permalink)
Tim Munro


 
 

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
Quote:

> 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:
>
Quote:

>> 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
Reply

Thread Tools


Similar Threads
Thread Forum
paaing variables from script to plink cmd VB Script
Include another script, keep variables in included script? PowerShell
Need help with PHP Script variables Network & Sharing
Pop-up to enter variables to pass to script PowerShell
Passing variables to script 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