Hi,
I'm trying to create a DL list with external users. I am able to add the email accounts to exchange online.
The script works fine when I used Add-DistributionGroupMember. As the list will change, I need to add and remove users which is why I'm trying to get it to work with Update-DistributionGroupMember.
The issue I'm getting is that it's updating each loop so it'll add one email address, then remove it to add the next email address. This leaves the last person in the list as the only one in the DL.
$file = Import-Csv "C:\external.csv"Foreach($line in $file)
{New-MailContact -Name $Line.Name -DisplayName $Line.Name -ExternalEmailAddress $line.ExternalEmailAddress -FirstName $line.FirstName -LastName $line.LastName
Set-MailContact $Line.Name -HiddenFromAddressListsEnabled $true}
Foreach($line in $file)
{Update-DistributionGroupMember -Identity "TestDL" -Member $line.ExternalEmailAddress -Confirm}
Any information or help would be greatly appreciated.