Checking for duplictes in AD Database

My organization has some custom attributes assigned to users. I am able to query on these attributes by selecting the property as well as write to the attribute. What I need to so is be able to have a script check to make sure that the data being provided isn’t already assigned to another user and return a warning if there is. I somewhat understand how to do this with SQL but the AD database isn’t SQL so not really sure how I can check that information.

Can you show us your script and give us an example of the attribute

You could do something like

Get-AdUser -Filter * -Properties attributename | group -Property attributename | sort Count -Descending | where Count -gt 1

If the attribute truly is unique then should get nothing back. Any duplicates will have a Count of 2 or more

This is not complex enough, I need to be able to enter the user name and enter what the value I want it to be. Then it needs to go through and search every user in the AD and make sure that number doesn’t exist.

Do your search as an LDAP filter on that attribute - is the attribute indexed in your AD for fast searches?