title: List of computers in Active Directory that are online
body: <p>I'm using this snippet of code to output a list of all the computers on my network (the language is jscript.net, but it's just a small manipulation of C#).</p>
  
  <pre><code>    var parentEntry = new DirectoryEntry();
  
      parentEntry.Path = "WinNT:";
      for(var childEntry in parentEntry.Children) {
          if(childEntry.SchemaClassName == "Domain") {
              var parentDomain = new TreeNode(childEntry.Name); 
              this.treeView1.Nodes.Add(parentDomain);
  
              var subChildEntry : DirectoryEntry;
              var subParentEntry = new DirectoryEntry();
              subParentEntry.Path = "WinNT://" + childEntry.Name;
              for(subChildEntry in subParentEntry.Children) {
                  var newNode1 = new TreeNode(subChildEntry.Name);
                  if(subChildEntry.SchemaClassName == "Computer") {
                      parentDomain.Nodes.Add(newNode1);
                  }
              }
          }
  
      }
  </code></pre>
  
  <p>I have 2 issues with this:</p>
  
  <p>1) It is <strong>extremely</strong> slow. There's about 100 computers showing, and it takes about 1 minute to load.</p>
  
  <p>2) I want to get only a list of computers that are currently <strong>online</strong>.</p>
  
  <p>This can be done because I've seen other programs doing it and they are much faster, also they're able to show only the ones online.</p>
  
  <p>Am I missing something?</p>