I was tasked today to "Export all UK AD users that have exchange custom attributes 3&4 to a excel sheet with their first name, last name and custom attributes 3 and 4 being displayed". I didn't think this task was very difficult as all I needed to do was export the list of attributes from AD after applying a custom filter to the view in the AD mmc to only show me users who had data present in the two fields. Unfortunately this wasn't the case as the custom view filter worked but the selecting of a column that specified the two attributes data in mmc wasn't available in the list as only the default ones of firstname lastname job description etc were available and so my export wouldn't show the data contained in the attributes obviously.
I was directed towards csvde ,a tool I had used very basically before but the parameters required would have taken me a while to compile seeing as I would have to have edited numerous times due to the users being in different OU's never mind the additional information I would need to clear down to get the information I needed.
So I elicited the help of Dave Wright and he pointed me to the far easier dsquery tool which simply searches using fairly basic ldap queries. The query we finally worked out was
dsquery * -filter "(&(&(objectcategory=person)(objectclass=user))(|(extensionattribute3=*)(extensionattribute4=*)))" -attr sn givenname extensionattribute3 extensionattribute4 -limit 0
We added the & and | parameters as we needed to find users who may have only had attribute four but not attribute three. The & parameter meaning and obviously and the | meaning or for those like me who didn't know | meant or.
We ran the query as a user of the domain we needed the information from as well as being on a machine that was on the domain we need it from. The query ran and the information was retrieved within a minute. I then just copied and pasted it out of command prompt into a excel file.
A massive thanks to Dave for his help with this as well as Matt Mould and Stuart Preston for offering help as well.
Regards
Gregg Robertson
_thumb.jpg)
_1079_1080_1078_thumb.jpg)