HOW TO: Enumerate GUIDs of All Computers in a Domain with Windows 2000 (315619)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Professional

This article was previously published under Q315619

SUMMARY

This step-by-step article describes how to enumerate GUIDs of all computers in a domain with Windows 2000. Specifically, this article describes how you can use the Active Directory Services Interface (ADSI) libraries to enumerate all of the computers in a Windows 2000 domain, along with the textual representation of the GUID for each computer.

back to the top

Requirements

  • A computer that is running Windows 2000 (or later), and that is operating in a domain that is managed by Active Directory.
  • A basic understanding of VBScript and ADSI programming.
back to the top

Enumerating Computers in the Active Directory

In this example, you will enumerate all of the computers in an Active Directory domain that is named "testone.local":
  1. Use Notepad or another ASCII editor to create a file that is named ShowGuid.vbs and that contains the following text:
    Option Explicit
    
    ' Declare variables
    Dim sDomain
    Dim oDomain
    Dim oComputer
    
    ' This string specifies the domain (change to suit your needs)
    sDomain = "LDAP://cn=Computers,dc=testone,dc=local"
    
    ' Open the domain specified by sDomain
    Set oDomain = GetObject(sDomain)
    
    ' Iterate through each computer in the domain
    For Each oComputer In oDomain
        ' Display name and GUID text on the screen
        WScript.Echo oComputer.Name & vbTab & oComputer.GUID
    Next
    					
  2. To enumerate computers in a different domain, edit the initialization string for sDomain. Consult your site administrators for appropriate settings.
back to the top

Verifying it Works

  1. Open a command prompt.
  2. Run the ShowGuid.vbs file from Cscript.exe to write output to the console. Cscript ShowGuid.vbs. The name of each computer in the domain will be shown along with a textual representation of its GUID. For example, the script output is 1db33f0cb30d4746af3b0f13862b8681, the Adsiedit.msc output is 0x1d 0xb3 0x3f 0x0c 0xb3 0x0d 0x47 0x46 0xaf 0x3b 0x0f 0x13 0x86 0x2b 0x86 0x81, and the LDAP output is objectGUID: 0c3fb31d-0db3-4647-af3b-0f13862b8681.
back to the top

Modification Type:MajorLast Reviewed:10/30/2003
Keywords:kbhowto kbHOWTOmaster KB315619 kbAudDeveloper