It's never a good idea to use "name" as identifier, as you can indeed match multiple entries. Use a unique-valued attribute, such as primarySMTPaddress, UPN or similar. GUID if you will. As for finding all the objects that might have the same name, use Get-Recipient.
Set-DistributionGroup shows error: The operation couldn't be performed because 'NAME' matches multiple entries
I made a powershell script to create a distributionlist in O365, it contains more, but this is not important for the issue.
Although I'm not the best scripter in town, what I do works for me :-) (so please keep it simple for me, to understand an answer)
$inputDL = Read-Host "Give a Name for the DL"
$mailadres = $InputDL.Tolower()+"@domainname.com" -replace " ",""
New-DistributionGroup -name $InputDL
Set-DistributionGroup -Identity $InputDL -PrimarySmtpAddress $mailadres
so far so good, this works, but the problem exists when there is a moderngroup with the same displayname
then the command to set a primairySMTPaddress with the last line shows the next error:
The operation couldn't be performed because '<name>' matches multiple entries.
- CategoryInfo : NotSpecified: (:) [Set-DistributionGroup], ManagementObjectAmbiguousException
- FullyQualifiedErrorId : [Server=xxxx,RequestId=xxxx,TimeStamp=1/8/2021 1:21:34 PM] [FailureCategory=Cmdle
t-ManagementObjectAmbiguousException] 4BEDA17B,Microsoft.Exchange.Management.RecipientTasks.SetDistributionGroup - PSComputerName : outlook.office365.com
how can I set the primarySMTPaddress to whatever I want, without the error?
it is almost the same as getting information from the distribution group, like:
Get-DistributionGroup -Identity $InputDL
The current operation is not supported on GroupMailbox.
- CategoryInfo : NotSpecified: (name:String) [Get-DistributionGroup], RecipientTaskException
- FullyQualifiedErrorId : [Server=xxxx,RequestId=xxx,TimeStamp=1/8/2021 1:59:38 PM] [FailureCategory=Cmdle
t-RecipientTaskException] 3BA80F2C,Microsoft.Exchange.Management.RecipientTasks.GetDistributionGroup - PSComputerName : outlook.office365.com
but with an extra parameter: -RecipientTypeDetails MailUniversalDistributionGroup
Get-DistributionGroup -Identity $InputDL -RecipientTypeDetails MailUniversalDistributionGroup
is shows the information of the distributiongroup i want info from, but it was to easy to think I could use the parameter in the SET command, that did not work
Exchange | Exchange Server | Management
-
Vasil Michev 123K Reputation points MVP Volunteer Moderator2021-01-11T08:22:41.587+00:00