HI,
You can try below script:
#Parameters
$AdminCenterURL="https://Crescent-admin.sharepoint.com"
#Setup Credentials to connect
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)
#add guest user to sharepoint online site
Add-SPOUser -Group "Marketing Visitors" -LoginName "George@NationalAquarium.com" -Site "https://Crescent.sharepoint.com/sites/Marketing"
https://www.sharepointdiary.com/2019/05/add-external-user-to-sharepoint-online-using-powershell.html