Listing03_WQL_Get_Computers (VBScript)

This code can be found in Chapter 5 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book "Managing Enterprise Active Directory Services"
' ISBN: 0-672-32125-4

On Error Resume Next
Dim wmi_path, wql_query
wmi_path = "winmgmts:root/directory/LDAP"
wql_query = "SELECT * FROM ds_computer"
Set Computers = GetObject(wmi_path).ExecQuery(wql_query)
If Err = 0 Then
   for each Computer in Computers
      WScript.Echo Computer.adsipath
   next
Else
   WScript.Echo ErrNumber, Err.Source, Err.Description
End If

This code has been viewed 852 times.

New from the creators of TechTasks.com: StatSheet.com