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

JavaScript Challenge: Counting Words

This is useful to render word clouds, emphasizing more commonly occurring words in a database.…

How to Install Secured Shell SSH on Windows

# Windows 10 & Server 2019 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0…

Hyper-V: Creating a New Virtual Machine

# Compulsory variables $hyperVHost='HYPERV007' $vmName='WindowsGoldenImage' $parentDirectory='C:\ClusterStorage\Volume5' $disk1Size='100GB' $memoryAllocation='8GB' $networkSwitch='PublicZone' $vlan='1005' $clusterName='DEV-CLUSTER05' # Optional variables $disk2Size=$false…