# FindLegacy.ps1 # PowerShell Version 2 script to find all Active Directory objects with # values assigned to linked multi-valued attributes that are the forward link. # The output should be redirected to a text file. These attributes of # these objects may not be taking advantage of link value replication (LVR) # if the values were assigned before the forest was at # Windows Server 2003 Forest functional level or above. # # Copyright (c) 2015 Richard L. Mueller # Version 1.0 - August 20, 2015 # Version 2.0 - September 4, 2015 - Search all naming contexts. # # ---------------------------------------------------------------------- # You have a royalty-free right to use, modify, reproduce, and # distribute this script file in any way you find useful, provided that # you agree that the copyright owner above has no warranty, obligations, # or liability for such use. # Specify a limit for the number of values. Only objects with at least # this number of values assigned to the attribute will be documented. $Limit = 100 # Retrieve all attributes from the schema that are multi-valued, linked, # and are the forward link (linkID is even). $SchemaNC = (Get-ADRootDSE).schemaNamingContext $NCs = (Get-ADRootDSE).NamingContexts $Attrs = Get-ADObject -SearchBase $SchemaNC ` -Filter {(isSingleValued -eq "FALSE") -and (linkID -Like "*")} ` -Properties lDAPDisplayName, linkID | Where {$_.linkID % 2 -eq 0} # Enumerate the attributes and find all objects with at least one value for each. ForEach ($Attr In $Attrs) { $AttrName = $Attr.lDAPDisplayName $ID = $Attr.linkID # Search each naming context. ForEach ($NC In $NCs) { $Names = Get-ADObject -SearchBase $NC -LDAPFilter "($AttrName=*)" -Properties $AttrName ` | Select distinguishedName, $AttrName # Enumerate all objects with at least one value for this linked multi-valued attribute. If ($Names) { ForEach ($Name In $Names) { # Only consider objects where the number of values is equal to or greater # than the specified limit. If ($Name.$AttrName.Count -ge $Limit) { # For each object output the DN, the attribute name, and the number of values. $Name.distinguishedName + ": " + $AttrName + " (" + $Name.$AttrName.Count + ")" } } } } }