September 17th, 2012

PowerTip: Examine Automatic Variables

Doctor Scripto
Scripter

Summary: Learn how to identify automatic variables.

Hey, Scripting Guy! Question How many types of automatic variables exist by default? And how would you discover such a thing?

Hey, Scripting Guy! Answer There are five types of automatic variables that exist by default.

To discover them, use the variable provider and the Get-Member cmdlet:

PS C:\> dir variable: -Force | gm | select typename | sort typename -Unique

TypeName

——–

System.Management.Automation.LocalVariable

System.Management.Automation.NullVariable

System.Management.Automation.PSVariable

System.Management.Automation.QuestionMarkVariable

System.Management.Automation.SessionStateCapacityVariable

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.