Display List of Computers in a Specific OU in VBA

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 3
Reputation: buffdaemon_live is an unknown quantity at this point 
Solved Threads: 0
buffdaemon_live buffdaemon_live is offline Offline
Newbie Poster

Display List of Computers in a Specific OU in VBA

 
0
  #1
Sep 4th, 2008
I have two OUs OU=Student and OU=Teachers and my root OU is

LDAP://dc=test,dc=labs,dc=edu

in the Student OU i have three computers named Std1,Std2,Std3 and three computers in Teachers OU named Tea1,Tea2,Tea3

I am writing a VBA script in Excel in which i want to display my Computers in that OU in a excel spreadsheets.

Computer Name Description OU

Std1 Student Computers Student

Std2 Student Computers Student

...................List goes on.......list of all computers in Student OU and Teachers OU

This is my script but its not working can anyone help me?
  1. Sub ListDomains()
  2.  
  3. Dim objNameSpace
  4. Dim Domain
  5. Dim ou
  6. Dim pcs
  7. Set objNameSpace = GetObject("LDAP://dc=test,dc=labs,dc=edu")
  8. For Each objDomain In objNameSpace
  9. ou = objDomain.Name
  10. objDomain.Filter = Array("Computer")
  11.  
  12. For Each objComputer In objDomain
  13. pcs = objComputer.Name
  14. Dim i
  15. For i = 0 To pcs.Count - 1
  16. Cells(i, 1) = pcs
  17. Next
  18. Next
  19. Next
  20.  
  21. End Sub
Last edited by cscgal; Sep 4th, 2008 at 5:42 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum


Views: 1536 | Replies: 0
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC