// GetOperatingSystemReport.cs // // Reports Operating System Info via WMI (Win32_OperatingSystem). // // Requires the System.Management package: // dotnet new console -o OperatingSystemReport // dotnet add package System.Management // (replace the generated Program.cs with this file, then dotnet run) // On .NET Framework, System.Management is already available — just // add a reference to it in your project. using System; using System.Management; var searcher = new ManagementObjectSearcher("SELECT Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory FROM Win32_OperatingSystem"); int count = 0; foreach (ManagementObject item in searcher.Get()) { Console.WriteLine($"Caption: {item["Caption"]}"); Console.WriteLine($"Version: {item["Version"]}"); Console.WriteLine($"OSArchitecture: {item["OSArchitecture"]}"); Console.WriteLine($"LastBootUpTime: {item["LastBootUpTime"]}"); Console.WriteLine($"FreePhysicalMemory: {item["FreePhysicalMemory"]}"); Console.WriteLine(new string('-', 40)); count++; } if (count == 0) { Console.WriteLine("No Operating System Info found."); } else { Console.WriteLine($"\n{count} Operating System Info found."); }