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, Windows.System.Profile.SystemManufacturers, ContentType=WindowsRuntime] [Windows.System.Profile.SystemManufacturers.SmbiosInformation]::SerialNumber
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
SerialNumber static property from the
SmbiosInformation class just like any other type.
Next time, we'll wrap things up with a brief discussion of the
SmbiosInformation class itself.