🟣 C# / .NET 6+
Get USB Controllers Report (C#)
Queries Win32_USBController via WMI (System.Management) and prints USB Controllers to the console.
GetUSBControllerReport.cs
// GetUSBControllerReport.cs
//
// Reports USB Controllers via WMI (Win32_USBController).
//
// Requires the System.Management package:
// dotnet new console -o USBControllerReport
// 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_USBController");
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 USB Controllers found.");
}
else
{
Console.WriteLine($"\n{count} USB Controllers found.");
}