// BackupProcessorListToJson.cs // // Snapshots Processor Info (Win32_Processor) to a timestamped JSON file. // // Requires the System.Management package: // dotnet new console -o BackupProcessor // 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 Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed FROM Win32_Processor"); var results = new List>(); foreach (ManagementObject item in searcher.Get()) { var row = new Dictionary(); row["Name"] = item["Name"]; row["NumberOfCores"] = item["NumberOfCores"]; row["NumberOfLogicalProcessors"] = item["NumberOfLogicalProcessors"]; row["MaxClockSpeed"] = item["MaxClockSpeed"]; results.Add(row); } string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); string outPath = $"processor-snapshot_{timestamp}.json"; File.WriteAllText(outPath, JsonSerializer.Serialize(results, new JsonSerializerOptions { WriteIndented = true })); Console.WriteLine($"Snapshot of Processor Info ({results.Count} items) saved to {outPath}");