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