microsoft / adfsToolbox

A collection of PowerShell scripts for managing AD FS
MIT License
121 stars 29 forks source link

Error when the service has a UPN user where the domain from UPN is not the correct to "domain\username" format #79

Open asmialoski opened 3 years ago

asmialoski commented 3 years ago

I have experienced an error in the following snippet of the code (around line 1022):

Check for UPN style old name and convert to domain\username for SPN work items

        If ($OldName.ToString() -match "`@") 
        { 
            $OldName = ($OldName.Split("`@")[1]).ToString() + "\" + ($OldName.Split("`@")[0]).ToString() 
            Write-Host "`tUsing $OldName in order to meet SPN requirements" -ForegroundColor "gray" 
            ($ElapsedTime.Elapsed.ToString())+" [INFO]      Using $OldName in order to meet SPN requirements" | Out-File $LogPath -Append 
        } 

The error occurred because the old ADFS Service user was in the UPN format AND the domain part is not the same domain to use in the format 'domain\user'.

To solve, I need to change the user format in ADFS Service to 'domain\user' before to run the script again.