Is there a way to query OU's that Match a certain name, with the computer objects in it.
Example: I want to query all call computers, that are in an OU, that have the Name "Servers"
thank you for your help
Technology Tips and News
Is there a way to query OU's that Match a certain name, with the computer objects in it.
Example: I want to query all call computers, that are in an OU, that have the Name "Servers"
thank you for your help
Here you go:
$allcomputers = Get-ADComputer -Filter * foreach ($computer in $allcomputers) { if ($computer.DistinguishedName -like "*Server*") { $computer.name } }
Thank you for your reply. I was looking for something to query Active Directory. I have an application that I can do custom queries. this query gives me all the OU's that have the name "Server" , however, I need the computer in those OU's. (&(objectclass=organizationalunit)(name=Server))
Thank you.
Is there a way to query OU's that Match a certain name, with the computer objects in it.
Example: I want to query all call computers, that are in an OU, that have the Name "Servers"
thank you for your help
Run this via PowerShell in your Domain Controller. PowerShell is installed automatically if you have 2008 R2.
Import-Module activedirectory Get-ADComputer -Filter {name -like "*server*"} -Searchbase "OU=Computers,DC=Contoso,DC=com" | FT
For LDAP filters, only equality operator is allowed for the DistinguishedName. Richard already described that here: http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx
If only LDAP filters are allowed for searching then you won't be allowed to search based on the DN. However, you might think about the following: