Posted On April 30, 2021

PowerShell: Check ADFS for Duplicate Identifiers

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Check ADFS for Duplicate Identifiers
function checkDuplicateIdf{
    write-host "Checking each relying party trust for any duplicates of identifiers..."
    $trusts=Get-AdfsRelyingPartyTrust
    $allTrustNames=$trusts.Name
    foreach ($trustName in $allTrustNames){
        write-host "Checking $trustName..." -NoNewline
        $targetTrust=Get-AdfsRelyingPartyTrust $trustName
        $targetIdentifiers=$targetTrust.Identifier
        $otherTrustNames=$allTrustNames|?{$_ -ne $trustName}
        $otherTrusts=Get-AdfsRelyingPartyTrust $otherTrustNames
        $otherIdentifiers=$otherTrusts.Identifier
        $duplicateIdentifiers=$targetIdentifiers|?{$_ -in $otherIdentifiers}
        if($duplicateIdentifiers){
            write-host "$trustName has these duplicate identifiers"
            foreach ($duplicate in $duplicateIdentifiers){
                $duplicateTrust=$otherTrusts|?{$duplicate -in $_.Identifier}
                if($duplicateTrust){
                    write-host "$duplicate in $trustName and $($duplicateTrust.Name)"
                }
            }
        }else{
            write-host " no duplicates..."
        }
    }
    # $endPoints=(Get-AdfsEndpoint).FullUrl.AbsoluteUri
    # $endPoints|?{$_.FullUrl -like 'https://john.test.com'}   
}
checkDuplicateIdf

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Add New Virtual Disk to Existing Guest VM in Hyper-V

# Adding disks (optional) $newVMNames='TestWindows2019' $extraDiskSize='200GB' if($extraDiskSize){ foreach($newVmName in $newVMNames){ STOP-VM -vmname $newVmName $diskFile=(join-path $destinationFolder…

PowerShell: Maintain Windows Services Remotely via WinRM

# maintainServices.ps1 # FQDN of each computer name (required) $computerList=@' testWindows.intranet.kimconnect.com testWindows.dmz.dragoncoin.com '@ $serviceNames=@( 'windows_exporter',…

PowerShell: Check IP Conflicts of Computers in Active Directory

We have ran into issues where a group of virtual machines living on a DHCP…