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: Create New Hybrid On Prem Active Directory User with Office 365 Integration

# createNewHybridUser_v0.0.1.ps1# .Description: this script automates the creation of a user account in a hybrid…

PowerShell Script to Copy Members of One Group to Another

#Author: Kim Doan#Please tell me this code suck so that I can improve # Adding…

PowerShell: How to Replace a System File – For Experimentation Purposes

# When attempting to rename a system protected file such as notepad.exe $notepadExe='C:\Windows\system32\notepad.exe' $newNotePadExe='C:\Users\rambo\Desktop\notepad.exe' rename-item…