Results 1 to 4 of 4

Thread: VBS to extract Pc names From Active Directory

  1. #1
    Registered+
    Join Date
    Dec 2004
    Posts
    49
    Thanks
    0
    Thanked
    0 times in 0 posts

    VBS to extract Pc names From Active Directory

    Im trying to extract computer names from active directory into a text file, ive googled it and found this script.
    However it doesnt work, i guess i need to change some parts..but i dont have any idea which parts to change!!
    This is what i found..

    Set objDictionary = CreateObject("Scripting.Dictionary")
    i = 0
    Set objOU = GetObject("LDAP://CN=Computers, DC=fabrikam, DC=com")
    objOU.Filter = Array("Computer")
    For Each objComputer in objOU
    objDictionary.Add i, objComputer.CN
    i = i + 1
    Next
    For Each objItem in objDictionary
    Set colServices = GetObject("winmgmts://" & _
    objDictionary.Item(objItem) _
    & "").ExecQuery("Select * from Win32_Service")
    Wscript.Echo colServices.Count
    Next


    Do i just copy this into notepad and save it as a vbs file??
    Thanks
    Last edited by hegaroo; 05-07-2006 at 10:17 AM.

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    Surrey
    Posts
    299
    Thanks
    3
    Thanked
    4 times in 4 posts
    Hi,

    I think you do just copy it and save it as a vbs file

    You could use dsquery, although I'm not sure what kind of output your after.

    "dsquery computer >>computer.txt"

    EDIT: dsquery computer dc=nbs,dc=ad -o samid >>computer.txt might be better
    Last edited by mark19632; 05-07-2006 at 10:13 AM.
    Intel i5 2500K
    Gbyte Z68mx-ud3
    2x 4GB Corsair Vengance
    NEC ND3540A BLACK DVDR
    1TB HDD
    Sony SDM-HS75P 17" TFT
    Logitech Cordless Mouse and Keyboard LX700

  3. #3
    Registered+
    Join Date
    Dec 2004
    Posts
    49
    Thanks
    0
    Thanked
    0 times in 0 posts
    hi,
    im just after the computer names going into a notepad file.
    where do i put
    dsquery computer dc=nbs,dc=ad -o samid >>computer.txt

    and do i change dc=nbs to server name??

    I dont have a clue how it all works thats all..
    thanks

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Location
    Surrey
    Posts
    299
    Thanks
    3
    Thanked
    4 times in 4 posts
    This will out put to a txt file hopefull it's what you need.

    just change the dc=nbs,dc=ad to what ever your domain is eg "dc=microsoft,dc=com"

    HTH,

    Mark
    Intel i5 2500K
    Gbyte Z68mx-ud3
    2x 4GB Corsair Vengance
    NEC ND3540A BLACK DVDR
    1TB HDD
    Sony SDM-HS75P 17" TFT
    Logitech Cordless Mouse and Keyboard LX700

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Active Directory issue
    By Smudger in forum Software
    Replies: 9
    Last Post: 09-06-2006, 04:11 PM
  2. Signed installers in Active Directory
    By nameinuse in forum Software
    Replies: 8
    Last Post: 17-11-2005, 06:09 PM
  3. Microsoft Active Directory
    By Taz in forum Help! Quick Relief From Tech Headaches
    Replies: 5
    Last Post: 17-11-2005, 05:23 PM
  4. Replies: 8
    Last Post: 07-04-2004, 02:45 PM
  5. Active Directory
    By Raz316 in forum Software
    Replies: 2
    Last Post: 16-02-2004, 12:40 PM

Posting Permissions

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