$userId='kimconnect'
$groupName='Remote Desktop Users'

function addUserToGroup($userId,$groupName){
  $userExists=Get-ADGroupMember $groupName|?{$_.SamAccountName -eq $userId}
  if(!$userExists){
      Add-ADGroupMember -Identity $groupName -Members $userId
  }else{
      write-host "User ID '$userId' already exists in group '$groupName'"
  }
}

addUserToGroup $userId $groupName