Groups not getting added

Hi All,

I am trying to add a list of groups for a user. The names that is fetched are display names and due to that some groups could not be added since the identity names are different.

How could i make sure that these groups are also added.

$SamAccountName = "SAMAccountName"
$Groups = "#Group1;#Group -2,#Group -3"
 
$GroupArray = $Groups.Split(';')
$Group = @()
 
foreach ($item in $GroupArray){
try {
 
 
    Add-ADGroupMember -Identity $item $SamAccountName
} catch {
        "Group Name:$item not added for EmpID :$SamAccountName" | Out-File 'FilePath.txt' -Append
}
}