How should I gather Hardware Info if System.Management.dll
is not compatible with Dot Net Core.
How do I get the Machine info like Processo
I am currently porting a Net Framework project that uses System.Management
to get some hardware info, and I also got to a dead end because System.Management
is not compatible with Net Core.
The workaround I found was to use Process.Start
from System.Diagnostics
to execute powershell commands to get that information, for instance, to get the motherboard serial number you can use the command Get-WmiObject Win32_BaseBoard | select SerialNumber
, you can then change the command to process the output and only have the serial number, or even process the output programatically.
You can also add some ifs
, that depending on the current OS you can provide to the Process.Start
specific OS commands, for instance, for linux you would need to process a dmidecode related command.
The only negative side in this approach is that its A LOT SLOWER whem compared with System.Management
.