You could save the data to a CSV file, and store it in a location on your PC (e.g. C:\test\group.csv ), then you could use the command below to create the groups in bulk:
For on-prem:
Import-CSV “C:\test\group.csv” | foreach {New-DistributionGroup -Name $_.Name -Alias $_.Alias -DisplayName $_.Displayname -SamAccountName $_.SamAccountName -OrganizationalUnit $_.OrganizationalUnit}
For Online, note that the -SamAccountName is available only in on-premises Exchange. And you need to connect to exchange online powershell firstly
Import-CSV “C:\test\group.csv” | foreach {New-DistributionGroup -Name $_.Name -Alias $_.Alias -DisplayName $_.Displayname}
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.