dlo32
asked on
Powershell script to locate any user object with a duplicate or blank ExtensionAttribute
I need some help from someone versed in Powershell. I am trying to locate user objects that have either a duplicate value for ExtensionAttribute11, or have are blank/null value.
Anyone have something similar in a separate scripts or know how best to create this?
Anyone have something similar in a separate scripts or know how best to create this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANK YOU!!!!
ASKER
Hello - LVL85 - Is there an easy way to add the organizational unit that the duplicate accounts are located in?
Is there an easy way to add the organizational unit that the duplicate accounts are located in?
Modified the script by oBdA to show the CanonicalName property as well:
$Attribute = 'ExtensionAttribute11'
$ADUsers = Get-ADUser -Filter * -ResultSetSize $Null -Properties $Attribute, CanonicalName | Select-Object -Property SamAccountName, CanonicalName, $Attribute, @{n='Duplicate'; e={}}
$ADUsers | Where-Object {-not $_.$Attribute}
$ADUsers | Where-Object {$_.$Attribute} | Group-Object -Property $Attribute | Where-Object {$_.Count -gt 1} | ForEach-Object {
$Duplicates = ($_.Group | Select-Object -ExpandProperty SamAccountName | Sort-Object) -join ', '
$_.Group | Select-Object -Property SamAccountName, CanonicalName, $Attribute, @{n='Duplicate'; e={$Duplicates}}
}
Works for me, hope this helps anyone.
Open in new window
Something like this should work