🟣 C# / .NET 6+
Backup BIOS Info to JSON (C#)
Snapshots BIOS Info (Win32_BIOS) to a timestamped JSON file via System.Management and System.Text.Json.
BackupBIOSListToJson.cs
// BackupBIOSListToJson.cs
//
// Snapshots BIOS Info (Win32_BIOS) to a timestamped JSON file.
//
// Requires the System.Management package:
// dotnet new console -o BackupBIOS
// 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, SMBIOSBIOSVersion, SerialNumber, ReleaseDate FROM Win32_BIOS");
var results = new List<Dictionary<string, object?>>();
foreach (ManagementObject item in searcher.Get())
{
var row = new Dictionary<string, object?>();
row["Manufacturer"] = item["Manufacturer"];
row["SMBIOSBIOSVersion"] = item["SMBIOSBIOSVersion"];
row["SerialNumber"] = item["SerialNumber"];
row["ReleaseDate"] = item["ReleaseDate"];
results.Add(row);
}
string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss");
string outPath = $"bios-snapshot_{timestamp}.json";
File.WriteAllText(outPath, JsonSerializer.Serialize(results, new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine($"Snapshot of BIOS Info ({results.Count} items) saved to {outPath}");