How do I get the computer’s serial number? Consuming Windows Runtime classes in desktop apps, part 5: PowerShell

Raymond Chen

Continuing our series on getting the computer’s serial number in desktop apps in various languages, we look at PowerShell.

I warned you that you’re going to be underwhelmed, so prepare to be underwhelmed.

# The following line has been broken up for readability purposes.
# Make sure to glue them together into one long line.
# (The continuation character doesn't work here.)
$addType = [Windows.System.Profile.SystemManufacturers.SmbiosInformation,


The first thing we do is add the type to PowerShell, which we do by loading up the type from the Windows Runtime metadata. Specify the type, the parent namespace, and say ContentType = WindowsRuntime.

And that’s it. We can now obtain the Serial­Number static property from the Smbios­Information class just like any other type.

Next time, we’ll wrap things up with a brief discussion of the Smbios­Information class itself.


Discussion is closed.

Feedback usabilla icon