// GetPhysicalMemoryReport.cs // // Reports Physical Memory Modules via WMI (Win32_PhysicalMemory). // // Requires the System.Management package: // dotnet new console -o PhysicalMemoryReport // 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 BankLabel, Capacity, Speed, Manufacturer FROM Win32_PhysicalMemory"); int count = 0; foreach (ManagementObject item in searcher.Get()) { Console.WriteLine($"BankLabel: {item["BankLabel"]}"); Console.WriteLine($"Capacity: {item["Capacity"]}"); Console.WriteLine($"Speed: {item["Speed"]}"); Console.WriteLine($"Manufacturer: {item["Manufacturer"]}"); Console.WriteLine(new string('-', 40)); count++; } if (count == 0) { Console.WriteLine("No Physical Memory Modules found."); } else { Console.WriteLine($"\n{count} Physical Memory Modules found."); }