title: How do you find out the difference between workstations and servers on the network?
body: <p>I know how to get the machines on a server using the System.DirectoryServices network. 
  The issue is that I would like to ignore workstations/computers on the network and only retrieve servers. </p>
  
  <p>In case someone says to check the OS version, the problem with getting a Win NT family OS version number is that each number may correspond to both a server and non-server OS (such as NT version 6.1 referring both to Win 7 and Win Server 2008 R2).</p>
  
  <p>Here is my basic test class:</p>
  
  <pre><code>namespace Project1
  {
      class Class1
      {
          public static void Main(string[] args)
          {
               List&lt;string&gt; list = Class1.GetComputersOnNetwork();           
          }
  
          public static List&lt;string&gt; GetComputersOnNetwork()
          {
              string fileName = "networkcomputers.txt";  
  
              // Delete the file if it exists.
              if (System.IO.File.Exists(fileName))
              {
                  System.IO.File.Delete(fileName);
              }
  
              // Create the file.
              System.IO.FileStream fs = System.IO.File.Create(fileName, 1024);
  
              StreamWriter strwr = new StreamWriter(fs);
  
              int i = 0;
              List&lt;string&gt; list = new List&lt;string&gt;();
              DirectoryEntry root = new DirectoryEntry("WinNT:");           
              foreach (DirectoryEntry computers in root.Children)
              {                   
                  if ((computers.Name != "Schema"))
                  {
                      i++;
                      Console.WriteLine("Machine Number " + i + ": " + computers.Name);
                      strwr.WriteLine("Machine Number " + i + ": " + computers.Name);
                      list.Add(computers.Name);
                  }           
              }
              return list;
          }
      }
  }
  </code></pre>