Last active
March 21, 2022 19:26
-
-
Save kuan51/6e9f80ee0833dc3ce0c5354ad8fc7d13 to your computer and use it in GitHub Desktop.
Create Secret O365 Groups using CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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