You just have to love the simple things in this world that are not so obvious at first thought…
In AD if you try to search for computer name and would like to be slightly more specific you have a problem. Here is the default choice:
The rather obvious choice would include “computer name contains” but sadly the option is not there! Solution? Simple – use LDAP search string instead! In ADUC define new query with custom search for:
(&(objectcategory=computer)(name=*0112*))
where 0112 is what you’re looking for (or computer name contains)
Lightweight Directory Access Protocol – LDAP
Active Directory Users and Computers – ADUC
LDAP:
Icon: find objects in Active Directory Domain Services
> Change Find Dropdown-List from “Users, Contacts and Groups” to “Custom Search”
> Go to Advanced Tab
> Enter LDAP guery
that was awesome and EXACTLY what we needed. !!! Thank you
That is just awesome. Now I just need to figure out how to exclude computer accounts that is disabled in AD.
Thomas, please add (!userAccountControl:1.2.840.113556.1.4.803:=2) in your string to filter out disabled accounts. This should read as follows:
(&(objectcategory=computer)(name=*0112*)(!userAccountControl:1.2.840.113556.1.4.803:=2))
Hello Adrian
I’m trying to use your formula to search the Computer Description field for the word Asus. Shouldn’t this work:
(&(objectcategory=computer)(Description=*Asus*))
I get a blank when I execute it and I know there are Computers with Asus in the Description. Here is one: NERI – Grandview Maint Lunchroom Win7-64 Asus
Joe, apologies for late reply. I have number of machines with the word ‘Mini’ in the description and the following works as expected:
(&(objectCategory=computer)(description=*Mini*))
PowerShell is probably the way to go here as in:
Get-ADComputer -filter {Description -like “*Mini*”} | select name
gets you the same set of results as the LDAP statement above.
ldapsearch -t -x -D “[email protected]” -W -H ldaps://ldap.example.com:3269 -b “DC=example,DC=com” “(&(objectcategory=computer)(description=INNO0001.example.com))”
can someone tell me what wrong this to get the computer description
I am trying to filter by the 3rd char of the Server name, so something like
Get-ADComputer -Filter ‘Name -like “???r*”‘ | select-object name
I was using “?” for the place holder but that does not work, any ideas?
Hey,
I am not quite sure I follow what you are trying to do?
Are you saying the servers are named in such way that you want to essentially ignore first 3 characters and start your search on the 4th?
Please clarify and maybe give some server names (as examples) so we can move forward 😉
thanks for the quick response, examples of server names are
pq2rblabla01
ft5rblabla04
yu4rblabla06
so, the first 3 char signify location, however i need to look for the 4th char / filter by the 4th char. This letter signifies the environment. i need to patch servers in a certain environment.
thx.