How-to: List Computers

List all the computers in a given domain.

' ListComputers.vbs
On Error Resume Next
Set objDomain = GetObject("WinNT://SS64Domain")

WScript.echo "Domain : " + objDomain.name

For each objDomainItem in objDomain
  if objDomainItem.Class = "Computer" then
     WScript.echo objDomainItem.Name
  end if
Next

Examples

cscript listcomputers.vbs

“You own everything that happened to you. Tell your stories.
If people wanted you to write warmly about them, they should have behaved better” ~ Anne Lamott

Related VBScript commands

SearchAD - Search Active Directory for Users, Computers or groups.
ComputerInfo - List Computer properties (as shown in ADUC).
Equivalent PowerShell: Get-adComputer - Get one or more AD computers.


 
Copyright © 1999-2024 SS64.com
Some rights reserved