I need to read the SMBIOS serial number in a C# UWP app on RPi 3. I see that there is the type Windows.System.Profile.SystemManufacturers.SmbiosInformation.SerialNumber that should return the serial number, but says it is only supported in Windows Desktop Extensions, not Windows IoT Extensions. And when I try it, I get a System.UnauthorizedAccessException.
Passwordless SSH access. Check whether there are already keys on the computer you are using to connect to the Raspberry Pi. Upon entering this.
I don't think I can use any win32 API directly because Windows Store will not allow it. So how can this be done? Windows.System.Profile.SystemManufacturers.SmbiosInformation.SerialNumber is currently restricted to device companion apps: We are investigating making this API available to OEM apps on Windows IoT in a future release. There is not currently an API that can be called from a UWP to get the serial number. One alternative would be to pre-provision a text file with the data in a location that can be read by the app. Windows.System.Profile.SystemManufacturers.SmbiosInformation.SerialNumber is currently restricted to device companion apps: We are investigating making this API available to OEM apps on Windows IoT in a future release.
There is not currently an API that can be called from a UWP to get the serial number. One alternative would be to pre-provision a text file with the data in a location that can be read by the app.
I tried something similar. I don't think that is even possible to do what you suggest as a 'pre-provision'. I need to create a production level flash.ffu image that can be mass duplicated. Pretty much the only place I can find where I would be able to do that would be to add some calls to the ADK AddonKit OEM Customizations package in the oemcustomizations.cmd file that runs on every boot and runs a section of it on first boot. But to no avail. I tried a command line script to read the SMBIOS value using WMI, but this fails. I also tried using PowerShell remote to see if PowerShell can access it but this also fails.
The method I tried is by using WMI. Apparently WMI is not supported in Windows 10 IoT in either command shell or PowerShell. The script can read the registry and get the SMBIOS Data blob which OS saved to the registry, but the docs for that also say that this blob has an already blanked serial numbers due to a privacy concern for personal computers. IoT devices are absolutely should not be considered like a personal computer. I've seen MS employees state on these forums that the device is the app, or vice versa. At least that is the intent.
So UWP on these devices should actually be able to access the full OS features just like apps on Embedded Windows could in days gone. Currently, I'm having to use the unique hardware MAC address to develop a way to monitor unique devices, even if they have been reinstalled, or recovered through the recovery mechanism, or have a replaced the SD card with an updated card.
Ideally I want full asset management capabilities in my Windows 10 IoT devices. Notice that the serial number is the MAC address of the default Ethernet device. So that seems to suggest one fo the following possibilities: 1) the hardware manufacturer's serial number actually is the MAC address; 2) The UEFI boot code is overriding the actual SMBIOS values in hardware, or it is never retrieving that data in the first place. If #2 is what is happening, then this is a serious problem for asset management to not be able to retrieve the actual SMBIOS values because that would preclude any kind of meaningful asset management with mass produced preinstall device images.
Also, note that a UWP app cannot call a powershell script in order to access that data and write out data file, so that call would have to be done as a boot time script writing to a text file. And even with that option, the UWP app would need to be published to the store under a company account to be able to include the UWP capability to access files in the file system without explicit per file or folder user permission. Also note that the UEFI code is not possible to build and use unless the developer pays for an expensive annual EV code signing key. So I check Raspberry Pi docs and the device serial number can be displayed in Raspbian. What I get is this: pi@raspberrypi:$ cat /proc/cpuinfo processor: 0 model name: ARMv7 Processor rev 4 (v7l) BogoMIPS: 38.4 Features: half thumb fastmult vfp edsp neon vfpv3 tls idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer: 0x41 CPU architecture: 7 CPU variant: 0x0 CPU part: 0xd03 CPU revision: 4 Hardware: BCM2835 Revision: a02082 Serial: 000061 The serial number reported here exactly matches the serial number reported by 'get-ciminstance win32bios'. So at least for the Raspberry Pi 3 the serial number reported by both Raspbian and Windows 10 IoT is the same as the last 4 octets of the MAC address. Now i there were only a way a UWP app can retrieve the hardware MAC address.
If there is, and even if I can't get the real SMBIOS recorded serial number, (at least for this revision of the Raspberry Pi PCB board), I can be reasonably sure that this will be the same serial number after 8 leading 0's.