Samuel French
Samuel French

Reputation: 665

PowerShell Return Type

I am creating a test application to get system information.

When I run this command

[int] $cdCodeIntTest = Get-WmiObject win32_cdromdrive | select ConfigManagerErrorCode

According to the powershell program: it returns a "Selected.System.Management.ManagementObject", but the online documentation says that the type is a [uint32] (unsigned 32 bit integer).

How do I typecast the error code to an integer or hex value so that I can switch on the value at a later point?

Upvotes: 1

Views: 270

Answers (1)

Shay Levy
Shay Levy

Reputation: 126902

You need to expand the property to get just the value, otherwise you get back an object with one property (ConfigManagerErrorCode):

Get-WmiObject win32_cdromdrive | select -expand ConfigManagerErrorCode

Upvotes: 4

Related Questions