sebastienbo
asked on
How to get computer objects with OU path from AD?
I wonderd if there is a way to get a list of AD computer objects together with the OU path?
Example:
/computers/homecomputers/X Pmachines/ Host1.mydo main.test
/computers/homecomputers/X Pmachines/ Host2.mydo main.test
/computers/homecomputers/N Tmachines/ Host1.mydo main.test
Example:
/computers/homecomputers/X
/computers/homecomputers/X
/computers/homecomputers/N
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I believe my post satisfied the question asked.
Flip a coin, any of the 3 solutions (vbscript, csvde, adfind) were workable.
ASKER
SirBounty's solution was the most portable solution So I gave him the most points.
I also like the different approuch of LauraEHunterMVP and Pber by launching something external.
In most cases this makes coding less complicated (but dependant from those tools)
So I thank you all for the solutions, every one of them gave me the result that I was looking for.
I also like the different approuch of LauraEHunterMVP and Pber by launching something external.
In most cases this makes coding less complicated (but dependant from those tools)
So I thank you all for the solutions, every one of them gave me the result that I was looking for.
'=========================
Sub Filter_List_By_Site
Dim strDomainName
Dim objIADsContainer, objIADsComputer, objActiveOption
Dim strOUBits, arrOUBits, intOUBit
'MsgBox lstSiteFilter.Value
strDomainName = "YOURDOMAIN"
strComputers = ""
'MsgBox lstSiteFilter.Item(lstSite
If lstSiteFilter.Item(lstSite
strOUBits = "Your.FQDN\"
arrOUBits = Split(lstSiteFilter.Value,
For intOUBit = UBound(arrOUBits) -2 To LBound(arrOUBits) Step -1
strOUBits = strOUBits & Replace(Trim(arrOUBits(int
Next
spanSiteFilter.InnerHTML = strOUBits
'spanSiteFilter.InnerHTML = lstSiteFilter.Value
If lstSiteFilter.Item(lstSite
Set objIADsContainer = GetObject("WinNT://" & strDomainName)
objIADsContainer.Filter = Array("Computer")
Else
Set objIADsContainer = GetObject("LDAP://" & lstSiteFilter.Value)
objIADsContainer.Filter = Array("Computer")
End If
For Each objIADsComputer In objIADsContainer
If Left(objIADsComputer.Name,
strComputers = strComputers & Replace(objIADsComputer.Na
End If
Next
Else
spanSiteFilter.InnerHTML = ""
End If
End Sub
'=========================
In this case the selected option from the list box (lstSiteFilter.Item(lstSit
contains something like "Your.FQDN\Sites\Civic Centre\Computers\IT Computers\" and this procedure
returns the computers into another list box. You could just messagebox these out for testing.
Make sure you replace YOURDOMAIN with your domain name, and in the code, replace
Your.FQDN with your fully qualified domain name, like Microsoft.Local or something.
It's quite similar to Sir Bounty's. In my HTA I've also enumerated the OU's in the first place,
so I can select an OU from the list box and get the computers.
Hope that helps.
Regards,
Rob.