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 - variable display?

Reply
 
Old 11-21-2007   #1 (permalink)
Justin Rich


 
 

variable display?

is there a way to list out all variables?

i tend to leave my console up for days at a time and toss things in here and
there... can i get a list of what variables i have out there? can it show
the values?


also is there a time out period for those or do they last forever? if they
last, there is obviously a bit of a resource issue that could arise huh?

Thanks
Justin



My System SpecsSystem Spec
Old 11-21-2007   #2 (permalink)
Kiron


 
 

Re: variable display?

PowerShell keeps the variables in the Variable: PSProvider. You can view them like:

ls variable:

Variables are live throughout the session unless you remove or clear them.

--
Kiron
My System SpecsSystem Spec
Old 11-21-2007   #3 (permalink)
Marco Shaw [MVP]


 
 

Re: variable display?

Justin Rich wrote:
Quote:

> is there a way to list out all variables?
>
> i tend to leave my console up for days at a time and toss things in here and
> there... can i get a list of what variables i have out there? can it show
> the values?
>
>
> also is there a time out period for those or do they last forever? if they
> last, there is obviously a bit of a resource issue that could arise huh?
>
> Thanks
> Justin
>
>
Also check out:
http://groups.google.com/group/micro...53ca7e027eaa9f

Where Jeffrey Snover posts about "start-newscope"

Also, you can just create all variables beginning with $myvar, for
example, then you can easily do something like 'remove-variable myvar*'
to clear out all the variables you created.

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 11-28-2007   #4 (permalink)
Kirk Munro


 
 

Re: variable display?

Hi Justin,

I just want to add a few more things to what's already been said.

I have posted a powerful one-liner that can be used to retrieve all
variables, their values, descriptions, types, etc. here:
http://poshoholic.com/2007/09/18/ess...tem-variables/

If you don't follow a standard naming scheme as Marco has recommended, you
could always open a new PowerShell window and retrieve the variables in that
session, retrieve the variables in your old session, and compare the two to
see what has changed.

And one last hint: most (but not all!) of the system variables have
descriptions. I suspect your variables don't have descriptions (most people
don't create variables with descriptions). You could write a script to
retrieve all variables without descriptions whose name is not in the list of
system variables that don't have descriptions (and you could retrieve that
list from a new PowerShell session).

--
Kirk Munro
Poshoholic
http://poshoholic.com


"Justin Rich" <jrich523@xxxxxx> wrote in message
news:uSngMxGLIHA.4584@xxxxxx
Quote:

> is there a way to list out all variables?
>
> i tend to leave my console up for days at a time and toss things in here
> and there... can i get a list of what variables i have out there? can it
> show the values?
>
>
> also is there a time out period for those or do they last forever? if they
> last, there is obviously a bit of a resource issue that could arise huh?
>
> Thanks
> Justin
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
display variable PowerShell
Re: How to display a variable value in a dialog box and how to readuser input? VB Script
Re: How to display a variable value in a dialog box and how to read user input? VB Script
Display variable in balloon notification PowerShell
How can I ensure that a variable is a built-in powershell variable? 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