🟣 C# / .NET 6+
Backup Motherboard Info to JSON (C#)
Snapshots Motherboard Info (Win32_BaseBoard) to a timestamped JSON file via System.Management and System.Text.Json.
BackupBaseBoardListToJson.cs
// BackupBaseBoardListToJson.cs
//
// Snapshots Motherboard Info (Win32_BaseBoard) to a timestamped JSON file.
//
// Requires the System.Management package:
// dotnet new console -o BackupBaseBoard
// dotnet add package System.Management
// (replace the generated Program.cs with this file, then dotnet run)
using System;
using System.Collections.Generic;
using System.IO;
using System.Management;
using System.Text.Json;
var searcher = new ManagementObjectSearcher("SELECT Manufacturer, Product, SerialNumber FROM Win32_BaseBoard");
var results = new List<Dictionary<string, object?>>();
foreach (ManagementObject item in searcher.Get())
{
var row = new Dictionary<string, object?>();
row["Manufacturer"] = item["Manufacturer"];
row["Product"] = item["Product"];
row["SerialNumber"] = item["SerialNumber"];
results.Add(row);
}
string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss");
string outPath = $"baseboard-snapshot_{timestamp}.json";
File.WriteAllText(outPath, JsonSerializer.Serialize(results, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine($"Snapshot of Motherboard Info ({results.Count} items) saved to {outPath}");