Bulk remove secondary SMTP error

I’m a noob at PowerShell and as such I apologize if it’s too simple for to not get. so, I have a script online, I believe it’s by Ali Tajran. Can somehow be kind enough to take a look at script and the error and let guide me?

script:
Start-transcript -path C:\Users\user1\Desktop\Dry-Run\remove-smpt-address-5.log -append

Get all mailboxes

$Mailboxes = Get-DistributionGroupMember -Identity “Marketing” -ResultSize unlimited

Loop through each mailbox

foreach ($Mailbox.name in $Mailboxes) {

# Add the domain to remove
$Mailbox.EmailAddresses | Where-Object { $_.AddressString -like "*@xyz.com" } | ForEach-Object {

    # Remove the -WhatIf parameter after you tested and are sure to remove the secondary email addresses
    Set-Mailbox $Mailbox -EmailAddresses @{remove = $_ } -WhatIf

    # Write output
    Write-Host "Removing $_ from $Mailbox Mailbox" -ForegroundColor Green
}

}

Stop-Transcript

Error:

Cannot process argument transformation on parameter ‘Identity’. Cannot convert the “domain.com/Users/Doe, Jame” value of type “Microsoft.Exchange.Data.Directory.Management.ReducedRecipient” to type
“Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter”.
+ CategoryInfo : InvalidData: (:slight_smile: [Set-Mailbox], ParameterBindin…mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
+ PSComputerName : exchangeserver.domain.com

Thanks,

email address should be in the format Jwoods@contoso.com I think. Print and debug without wrapping $_ in quotes, just like Write-Output $_ before Set-Mailbox and see how is the format.