September 11th, 2014

PowerTip: Use PowerShell to Cast to WMI UInt Value Type

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to cast to the WMI UInt value type.

Hey, Scripting Guy! Question I am comparing data from WMI, and it seems strange. I found the value type is a UInt32, and when I looked it up, I found that it is an unsigned 32-bit integer. How can I use Windows PowerShell to create one of these?

Hey, Scripting Guy! Answer Use [uint32] and cast your normal integer to this type, for example:

PS C:\> [uint32]$a = 3

PS C:\> $a.GetType()

IsPublic IsSerial Name                                     BaseType           

——– ——– —-                                     ——–           

True     True     UInt32                                   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.