// BackupTimeZoneListToJson.cs // // Snapshots Time Zone Settings (Win32_TimeZone) to a timestamped JSON file. // // Requires the System.Management package: // dotnet new console -o BackupTimeZone // 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 Description, Bias, StandardName FROM Win32_TimeZone"); var results = new List>(); foreach (ManagementObject item in searcher.Get()) { var row = new Dictionary(); row["Description"] = item["Description"]; row["Bias"] = item["Bias"]; row["StandardName"] = item["StandardName"]; results.Add(row); } string timestamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); string outPath = $"timezone-snapshot_{timestamp}.json"; File.WriteAllText(outPath, JsonSerializer.Serialize(results, new JsonSerializerOptions { WriteIndented = true })); Console.WriteLine($"Snapshot of Time Zone Settings ({results.Count} items) saved to {outPath}");