Duplicate O365 Distribution Group via Powershell
-
Having a bit of trouble getting a PS script to complete without errors.
I have a Distro group which needs to be duplicated. I found a script via Technet, but it doesn't seem to work in this case.
https://gallery.technet.microsoft.com/office/How-to-duplicate-68467217
I need Group2 to be the same as Group1, but will have different members. As I understand, they the syntax should be:
DuplicateEXODG.ps1 –oldDGIdentity Market –newDGIdentity newMarket
However I get the following:
Cannot bind argument to parameter 'Identity' because it is null. + CategoryInfo : InvalidData: (:) [Set-DistributionGroup], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Set-DistributionGroup + PSComputerName : outlook.office365.com -ModeratedBy : The term '-ModeratedBy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\~\~\DuplicateEXODG.ps1:9 char:25 + -ModeratedBy $Group.ModeratedBy -ModerationEn ... + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-ModeratedBy:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Cannot bind argument to parameter 'Identity' because it is null. + CategoryInfo : InvalidData: (:) [Update-DistributionGroupMember], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Update-DistributionGroupMember + PSComputerName : outlook.office365.com
-
The script you referenced is nearly 4 years old.
-
At the bottom of this article there are a few PS commands, get-distributiongroup and then add-DGM are likely what you need to do.
https://technet.microsoft.com/en-us/library/bb124755(v=exchg.160).aspx (Get-DG)
https://technet.microsoft.com/en-us/library/bb124340(v=exchg.160).aspx (Add-DGM) -
Is this O365 tenant tied to an on-prem AD server? If so, was the distribution group created solely within O365 or within AD?
If it is tied to AD and the group was made within AD, then your going have to write a script that will do the same thing to AD only and not to O365.
-
Not tied to AD, never was.
-
@gjacobse said in Duplicate O365 Distribution Group via Powershell:
Not tied to AD, never was.
So export a list of members in the DG, and create a new DG and then add the members. I don't know if duplicate exists on O365.
-
Sorry I missed this earlier, but how are they duplicates if they don't have the same members? Same positions for different locations?