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