title: Retrieve Serial Port information with Microsoft.Management.Infrastructure
body: <p>In order to get information about Serial Port devices, with <code>System.Management</code>, we can do as described in <a href="https://stackoverflow.com/questions/2837985/getting-serial-port-information">Getting Serial Port Information</a>:</p>
  <pre><code>using System;
  using System.Management;
  using System.Collections.Generic;
  using System.Linq;
  using System.IO.Ports;        
  
  namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              using (var searcher = new ManagementObjectSearcher
                  (&quot;SELECT * FROM WIN32_SerialPort&quot;))
              {
                  string[] portnames = SerialPort.GetPortNames();
                  var ports = searcher.Get().Cast&lt;ManagementBaseObject&gt;().ToList();
                  var tList = (from n in portnames
                              join p in ports on n equals p[&quot;DeviceID&quot;].ToString()
                              select n + &quot; - &quot; + p[&quot;Caption&quot;]).ToList();
  
                  tList.ForEach(Console.WriteLine);
              }
  
              // pause program execution to review results...
              Console.WriteLine(&quot;Press enter to exit&quot;);
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  <p>How can this be achieved using <code>Microsoft.Management.Infrastructure</code>, I haven't managed to find examples and the documentation isn't detailed enough.</p>