Checking for duplictes in AD Database

Welcome Forums General PowerShell Q&A Checking for duplictes in AD Database

This topic contains 4 replies, has 3 voices, and was last updated by

 
Participant
2 years, 6 months ago.

  • Author
    Posts
  • #42497

    Participant
    Points: 0
    Rank: Member

    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.

  • #42509

    Participant
    Points: 0
    Rank: Member

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

  • #42527

    Participant
    Points: 0
    Rank: Member

    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

    • #42559

      Participant
      Points: 0
      Rank: Member

      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.

  • #42619

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Checking for duplictes in AD Database’ is closed to new replies.