+ Post New Thread
Results 1 to 5 of 5
Windows Thread, Scan domain for machines in Technical; Hi I would like to scan the domain for a list of all computers in the domain and what os ...
  1. #1

    Join Date
    Feb 2008
    Posts
    324
    Thank Post
    51
    Thanked 3 Times in 3 Posts
    Rep Power
    14

    Scan domain for machines

    Hi I would like to scan the domain for a list of all computers in the domain and what os they are running. Does anybody have a script or program.

    Thanks

  2. #2

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,816
    Thank Post
    873
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Have a look at Spiceworks, its free and does the job well.

  3. #3

    Dos_Box's Avatar
    Join Date
    Jun 2005
    Location
    Preston, Lancashire
    Posts
    9,824
    Thank Post
    580
    Thanked 2,161 Times in 986 Posts
    Blog Entries
    23
    Rep Power
    627
    I shall also direct you to this article we did earlier: EduGeek.net - An EduGeek Roundup of Free Network Monitoring Tools please be aware though that none are 100 perfect at detecting all computers and devices although Spiceworks and the Dude are the two easiest to get up and running.

  4. #4
    Devontechie's Avatar
    Join Date
    Nov 2007
    Location
    UK
    Posts
    889
    Thank Post
    177
    Thanked 196 Times in 160 Posts
    Rep Power
    70
    Quote Originally Posted by FN-GM View Post
    Have a look at Spiceworks, its free and does the job well.
    I agree with giving Spiceworks ago. It is fairly easy to setup aswell.

    I have got it running on server at work which then has remote sites reporting back with the details of the computers/printers/IP phones etc. I have between 15 and 20 sites reporting back

  5. #5

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    This script will output the information you requested from AD:

    Code:
    On Error Resume Next
    
    ' Mehtod Constants
    Const adUseClient = 3
    Const adCmdText = 1
    Const adSecureAuthentication = 1
    Const adLockReadOnly = 1
    
    ' Declare Variables
    Dim shell, fso, adoConnection, adoCommand, adoRecordset
    Dim organisationUnit
    Dim textStream
    
    ' Set Configuration Variables
    organisationUnit = "DC=school,DC=local"
    
    ' Create System Objects
    Set shell = CreateObject("Wscript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    ' Ensure the script runs via cscript instead of wscript
    If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then
    	shell.Run "cscript """ & WScript.ScriptFullName & """", 1, False
    	WScript.Quit
    End If
    
    ' Clear the error state
    Err.Clear
    
    '==================================================='
    ' Connect to Active Directory                       '
    '==================================================='
    
    WScript.Stdout.Write "Connecting to Active Directory... "
    
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Properties("Encrypt Password") = True
    adoConnection.Properties("ADSI Flag") = adSecureAuthentication
    adoConnection.Open "Active Directory Provider"
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    WScript.Stdout.WriteLine "Done."
    
    '==================================================='
    ' Open Output File                                  '
    '==================================================='
    
    WScript.Stdout.Write "Opening output file 'computers.csv'... "
    
    Set textStream = fso.CreateTextFile("computers.csv", true)
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    textStream.WriteLine("""Name"",""OS"",""OS Service Pack"",""OS Version""")
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    WScript.Stdout.WriteLine "Done."
    
    '==================================================='
    ' Query Active Directory for Computers              '
    '==================================================='
    
    WScript.Stdout.Write "Querying Active Directory for computers... "
    
    Set adoCommand = CreateObject("ADODB.Command")
    Set adoRecordset = CreateObject("ADODB.Recordset")
    adoCommand.ActiveConnection = adoConnection
    adoCommand.Properties("Page Size") = 1000000
    adoCommand.Properties("Sort On") = "cn"
    adoCommand.CommandType = adCmdText
    adoCommand.CommandText = "<LDAP://" & organisationUnit & ">;(objectCategory=Computer);name,operatingSystem,operatingSystemServicePack,operatingSystemVersion;subtree"
    adoRecordset.Open adoCommand, , adUseClient, adLockReadOnly
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    '==================================================='
    ' Process Computers                                 '
    '==================================================='
    
    WScript.Stdout.WriteLine adoRecordset.RecordCount & " Found."
    
    While Not adoRecordset.EOF And Not adoRecordset.BOF
    	' Write computer information
    	textStream.Write("""")
    	textStream.Write(adoRecordSet("name"))
    	textStream.Write(""",""")
    	textStream.Write(adoRecordSet("operatingSystem"))
    	textStream.Write(""",""")
    	textStream.Write(adoRecordSet("operatingSystemServicePack"))
    	textStream.Write(""",""")
    	textStream.Write(adoRecordSet("operatingSystemVersion"))
    	textStream.WriteLine("""")
    	
    	adoRecordset.MoveNext
    Wend
    
    Err.Clear
    
    '==================================================='
    ' Close Active Directory Connection                 '
    '==================================================='
    
    WScript.Stdout.Write "Closing Active Directory Connection... "
    
    adoConnection.Close
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    WScript.Stdout.WriteLine "Done."
    
    '==================================================='
    ' Close Output File                                 '
    '==================================================='
    
    WScript.Stdout.Write "Closing output file... "
    
    textStream.Close()
    
    If Err.Number <> 0 Then
    	WScript.Stdout.WriteLine "Failed!"
    	WScript.Stdout.WriteLine
    	WScript.Stdout.WriteLine "Error: " & Err.Number & ": " & Err.Description
    	WScript.Stdout.WriteLine
    	WScript.Quit
    End If
    
    WScript.Stdout.WriteLine "Done."
    Last edited by ChrisMiles; 29th November 2012 at 09:01 AM.

SHARE:
+ Post New Thread

Similar Threads

  1. DNS Resolution fails for non-domain joined machines
    By vladker in forum Windows Server 2000/2003
    Replies: 8
    Last Post: 12th November 2013, 04:15 AM
  2. Replies: 1
    Last Post: 17th June 2008, 12:41 PM
  3. Help me choose domain for new Academy!
    By kujina in forum Web Development
    Replies: 17
    Last Post: 30th April 2008, 10:16 AM
  4. Replies: 7
    Last Post: 21st August 2007, 01:11 PM
  5. AD Permissions for machine rename
    By DrFrankenMouse in forum Windows
    Replies: 1
    Last Post: 3rd August 2007, 11:00 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •