Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

want to write a Vb Script to get the full information on all the host name, and ip address and sub net mask of computer that has been added to the domain control.

share|improve this question
Your 'question' goes a bit beyond the scope of what can be reasonable answered. Also there are many existing tools which can do this. Most people will not write this for you. If still want to write it yourself you may want to start working on it and post specific questions about what you are having problems doing on stackoverflow. – Zoredache May 3 '10 at 22:15

Your best bet is to check out the microsoft script center where much of that has been written for you. The script center has tutorials as well as the script repository where windows admins share scripts. You should also take a look at the scriptomatic, an HTA application that can generate wmi reader code for you

share|improve this answer

Here is a VBS script, adapted from this page (look for "list Domain, computer and IP of all computers in AD"):

' Modify these vars to match your enviroment
' requires Windows 2003 DNS

strDomain = "MyWindowsDomain"     ' Windows Domain NetBIOS Name
strDNSSVR = "DNSserver"           ' DNS Server's name or IP
strDNSDomain = ""    ' Note the . at the beginning!
strFILENAME = "AD-Computers.txt"   ' Output File Name

' File stuff
Dim filesys, testfile 
Set filesys = CreateObject("Scripting.FileSystemObject") 
Set OUTfile= filesys.CreateTextFile(strFILENAME, True)


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://" & strDomain & "' " _
        & "Where objectCategory='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute

'debug stuff   Comment if you want to see it during execution
'Wscript.Echo "My DNS Server is: " & strDNSSVR
'Wscript.Echo "My Windows Domain is: " & strDomain
'Wscript.Echo "My DNS Suffix is: " & strDNSDomain
'Wscript.echo "Writing output to File: " & strFILENAME

Do Until objRecordSet.EOF
    strHOST = objRecordSet.Fields("Name").Value
    strHOSTFQDN = strHOST & strDNSDomain
    strIP = GetIPFromDNS(strHOSTFQDN,strDNSSVR)
    OUTfile.WriteLine strDomain & " " & strHOST & " " & strIP
    'Comment line below to not dump output to screen
    Wscript.Echo strDomain & " " & strHOST & " " & strIP

Function GetIPFromDNS(sFQDN, strDNS)
  Set objWMI=GetObject("WinMgmts://" & strDNS & "\root\microsoftDNS")    
  Set colIP=objWMI.ExecQuery("Select * from MicrosoftDNS_AType where ownerName='" & sFQDN & "'")     
    For Each item In colIP          
        GetIPFromDNS = item.RecordData     
End Function

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.