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: Check DotNet Framework on Windows

function checkDotNetVersions{ # General info: # - Powershell 2.0 latest SSL version support is TLS…

PowerShell: Checking Duplicating Identifiers Among ADFS Relying Party Trusts

function getDuplicatingIfd{ write-host "Checking each relying party trust for any duplicates of identifiers..." $trusts=Get-AdfsRelyingPartyTrust $allTrustNames=$trusts.Name…

PowerShell: Reset Windows 10 to Default Factory Settings

The easiest (GUI) method: systemreset -cleanpc The automated method: # Experimental code: not working yet…