How To Add 365 Distro Groups, Group Members, Contacts in Bulk via PowerShell

  • Post author:
  • Post category:Microsoft

To create distribution groups in bulk

Import-CSV “C:\Scripts\DistroNames.csv” | foreach {New-DistributionGroup -Name $ -PrimarySmtpAddress $_.PrimaryEmail -Type $_.Type -RequireSenderAuthenticationEnabled $False}

Fields in CSV: Name Alias PrimaryEmail Type
Example: Webmasters webmasters [email protected] Distribution

To create contacts in bulk

Import-Csv "C:\Scripts\Contacts.csv" | foreach-object { New-MailContact -Name $_.MyName -ExternalEmailAddress $_.MyPrimaryEmail }

Fields in CSV: MyName MyPrimaryEmail
Bill Gates [email protected]

To add members or contacts to distribution groups in bulk

Import-Csv “C:\Scripts\DistroMembers.csv” | foreach{Add-DistributionGroupMember -Identity $_.identity -Member $_.members}

Fields in CSV: Identity Members
Webmasters [email protected]
Webmasters [email protected] (put each member on its own line)


Jason works as a project specialist at an IT MSP in Pennsylvania, USA. He's an IT/security professional with 20 years experience.