PowerTip: Use PowerShell to Cast to WMI UInt Value Type

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  

Comments (0)

Skip to main content