November 6th, 2013

PowerTip: Find the Type of an Object

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to find the type of an object.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find the type of object that is stored in a variable?

Hey, Scripting Guy! Answer Use the GetType method (which all objects have):

PS C:\> $date = get-date

PS C:\> $date.GetType()

 

IsPublic IsSerial Name                     BaseType

——– ——– —-                             ——–

True     True     DateTime                  System.ValueType 

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.

Feedback