🟣 C# / .NET 6+

Get Sound Devices Report (C#)

Queries Win32_SoundDevice via WMI (System.Management) and prints Sound Devices to the console.

By WindowsScripting.com · 975 B
GetSoundDeviceReport.cs
// GetSoundDeviceReport.cs
//
// Reports Sound Devices via WMI (Win32_SoundDevice).
//
// Requires the System.Management package:
//   dotnet new console -o SoundDeviceReport
//   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 Name, Manufacturer, Status FROM Win32_SoundDevice");
int count = 0;

foreach (ManagementObject item in searcher.Get())
{
    Console.WriteLine($"Name: {item["Name"]}");
    Console.WriteLine($"Manufacturer: {item["Manufacturer"]}");
    Console.WriteLine($"Status: {item["Status"]}");
    Console.WriteLine(new string('-', 40));
    count++;
}

if (count == 0)
{
    Console.WriteLine("No Sound Devices found.");
}
else
{
    Console.WriteLine($"\n{count} Sound Devices found.");
}