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 - How can I ensure that a variable is a built-in powershell variable?

Reply
 
Old 09-19-2006   #1 (permalink)
Sung M Kim


 
 

How can I ensure that a variable is a built-in powershell variable?


I have a question regarding variables.
Is there a way to ensure that retrieved variable such as *Preference
variables are indeed a built-in PowerShell variables?(they have "None"
as an option for all)

I was thinking about checking if a variable is of type
"System.Management.Automation.ActionPreference" but can anyone just
create a variable with *Preference as postfix and of type
"System.Management.Automation.ActionPreference"?

Any ideas?

- Sung


My System SpecsSystem Spec
Old 09-19-2006   #2 (permalink)
Adam Milazzo


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

Sung M Kim wrote:
> I have a question regarding variables.
> Is there a way to ensure that retrieved variable such as *Preference
> variables are indeed a built-in PowerShell variables?(they have "None"
> as an option for all)
>
> I was thinking about checking if a variable is of type
> "System.Management.Automation.ActionPreference" but can anyone just
> create a variable with *Preference as postfix and of type
> "System.Management.Automation.ActionPreference"?


Sure, anybody can, but why not let them?
My System SpecsSystem Spec
Old 09-20-2006   #3 (permalink)
Sung M Kim


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

Adam Milazzo wrote:
> Sung M Kim wrote:
> > I have a question regarding variables.
> > Is there a way to ensure that retrieved variable such as *Preference
> > variables are indeed a built-in PowerShell variables?(they have "None"
> > as an option for all)
> >
> > I was thinking about checking if a variable is of type
> > "System.Management.Automation.ActionPreference" but can anyone just
> > create a variable with *Preference as postfix and of type
> > "System.Management.Automation.ActionPreference"?

>
> Sure, anybody can, but why not let them?


I was simply trying to retrieve variables that affect PowerShell's
behavior, not the ones that do nothing to how PowerShell works...
And I just wanted to know if there is a way or a flag to check against
for built-in variables

My System SpecsSystem Spec
Old 09-20-2006   #4 (permalink)
klumsy@xtra.co.nz


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

with the release of powershell (whatever version), there is always
going to be a set of variables are part of powershell, and this is only
goiung to be a handful, so i think a function with them hard coded
would suffice..

however a question and a presumption: i presume that a powershell
variable is there 1) regardless of the host, and is there for the
entire lifespan of the shell?

Karl

My System SpecsSystem Spec
Old 09-20-2006   #5 (permalink)
Adam Milazzo


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

klumsy@xtra.co.nz wrote:
> however a question and a presumption: i presume that a powershell
> variable is there 1) regardless of the host, and is there for the
> entire lifespan of the shell?


No, they could be removed by the user or the host at any time...
My System SpecsSystem Spec
Old 09-20-2006   #6 (permalink)
klumsy@xtra.co.nz


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

i didn't know they could be removed.. still if they are static , a
defined list, you could make a function that has t hem hard coded, and
checks for their existence.

Adam Milazzo wrote:
> klumsy@xtra.co.nz wrote:
> > however a question and a presumption: i presume that a powershell
> > variable is there 1) regardless of the host, and is there for the
> > entire lifespan of the shell?

>
> No, they could be removed by the user or the host at any time...


My System SpecsSystem Spec
Old 09-22-2006   #7 (permalink)
Lee Holmes [MSFT]


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

The only way currently to find an exhaustive list is the documentation:
"get-help about_automatic_variables." Other than that, we do not currently
attach any metadata to them.

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message
news:1158753822.808445.112870@b28g2000cwb.googlegroups.com...
> Adam Milazzo wrote:
>> Sung M Kim wrote:
>> > I have a question regarding variables.
>> > Is there a way to ensure that retrieved variable such as *Preference
>> > variables are indeed a built-in PowerShell variables?(they have "None"
>> > as an option for all)
>> >
>> > I was thinking about checking if a variable is of type
>> > "System.Management.Automation.ActionPreference" but can anyone just
>> > create a variable with *Preference as postfix and of type
>> > "System.Management.Automation.ActionPreference"?

>>
>> Sure, anybody can, but why not let them?

>
> I was simply trying to retrieve variables that affect PowerShell's
> behavior, not the ones that do nothing to how PowerShell works...
> And I just wanted to know if there is a way or a flag to check against
> for built-in variables
>



My System SpecsSystem Spec
Old 09-22-2006   #8 (permalink)
Sung M Kim


 
 

Re: How can I ensure that a variable is a built-in powershell variable?

Lee Holmes [MSFT] wrote:
> The only way currently to find an exhaustive list is the documentation:
> "get-help about_automatic_variables." Other than that, we do not currently
> attach any metadata to them.


Thank you for the response.
Yes, Metadata for variable was what I was looking for basically...
I guess I am going to have to deal with this for the current drop

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Powershell - outer variable PowerShell
How to perform variable substitution in powershell? PowerShell
Changing the PATH variable in the registry with Powershell PowerShell
Copying a VBS variable in powershell? PowerShell
Re: Copying a VBS variable in powershell? 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