File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 2727 Write-Verbose - Message " Beginning ${MyInvocation.InvocationName} ..."
2828 }
2929
30+ $SIDHistoryList = [ordered ]@ {}
3031 $DomainSIDs = New-Object - TypeName System.Collections.Generic.List[System.String ]
3132 } # end begin
3233
3334 process {
3435 # Get all ActiveDirectory objects that have SID history.
35- $AllSIDHistory = Get-ADObject - Filter { SIDHistory -like ' *' } - Properties SIDHistory | Select-Object - ExpandProperty SIDHistory
36+ $ADObjectsWithSIDHistory = Get-ADObject - Filter { SIDHistory -like ' *' } - Properties SIDHistory | Select-Object * - ExpandProperty SIDHistory
3637
37- foreach ($SID in $AllSIDHistory ) {
38- $DomainSIDs.Add ($SID.Substring (0 , $SID.LastIndexOf (' -' )))
38+ foreach ($object in $ADObjectsWithSIDHistory ) {
39+ # Create a hash table of DistinguishedName and SIDHistory for each object.
40+ $SIDHistoryList.Add ($object.DistinguishedName , $object.SIDHistory )
41+ # Create a de-duplicated list of source domain SIDs from the SIDHistory attribute of each object.
42+ $DomainSIDs.Add ( $ ($object.SIDHistory.Substring (0 , $SID.LastIndexOf (' -' ))) )
3943 }
4044 } # end process
4145
You can’t perform that action at this time.
0 commit comments