This script will help you to create multiple M365 groups if you come across where situation create list of M365 groups.
Script:
<#
- Make sure create a .csv file called M365list.csv
- Make sure to include display name and alias (refer the image1).
- Make sure to locate script and M365list.csv in the same folder.
- Script required Connect-msolservice as a prerequisites and make sure to import it if you doesn't have it already.
- Script will require global admin permission to perform M365 group creation successfully.
#>
$UserCredential = Get-Credential
Connect-MsolService -Credential $UserCredential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
$loc = Get-Location
$data = import-csv "$loc\M365List.csv"
foreach ( $cdata in $data)
{
$dpname = $cdata.displayname
$aname = $cdata.alias
New-UnifiedGroup -DisplayName $dpname -Alias $aname
}
Image1:
Thank You!