Not able to use this command

HI all,
need your help to get this code running untill i enter right user
This loop is working just for one user

this is the full script

While (!$SourceUser) {
$copyfrom = Read-Host -Prompt “Copy Groups From”

Try {
    $SourceUser = Get-ADUser -Identity $copyfrom -Properties memberof
}
Catch {
    $copyfrom = Read-Host -Prompt "User not found.  Please enter a user to copy groups from"
}

}
$SourceUser = Get-ADUser -Identity $copyfrom -Properties memberof
$SelectedGroups = $SourceUser.memberof |
Add-ADGroupMember -Members $username -PassThru |
Select-Object -ExpandProperty Name
any other idea?

Define “right user”!

If you want to get asked if the user you just entered is the one you want to move on with you should utilize the pormpt for choice method.

https://kpatnayakuni.com/2019/01/15/just-a-tip-6-prompt-for-choice-in-powershell/

https://4sysops.com/archives/read-host-and-the-choicedescription-class-prompt-for-user-input-in-powershell/

https://social.technet.microsoft.com/wiki/contents/articles/24030.powershell-demo-prompt-for-choice.aspx

Thank you all i found a solution