Skip to content

Instantly share code, notes, and snippets.

@kuan51
Last active March 21, 2022 19:26
Show Gist options
  • Save kuan51/6e9f80ee0833dc3ce0c5354ad8fc7d13 to your computer and use it in GitHub Desktop.
Save kuan51/6e9f80ee0833dc3ce0c5354ad8fc7d13 to your computer and use it in GitHub Desktop.
Create Secret O365 Groups using CSV
# Create a Distribution List with Hidden Membership using a CSV of contacts
import-module AzureAd
Import-Module ExchangeOnlineManagement
Connect-AzureAD
Connect-ExchangeOnline
$csv = Import-Csv C:\Users\username\Documents\Investors.csv
foreach($investor in $csv)
{
New-MailContact -Name $investor.Name -ExternalEmailAddress $investor.Email
Add-DistributionGroupMember -Identity "Investors" -Member $investor.Email
}
New-DistributionGroup -Name Investors -HiddenGroupMembershipEnabled:$true
foreach($investor in $csv)
{
Add-DistributionGroupMember -Identity "Investors" -Member $investor.Email
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment