Hi Microsoft 365 friends,
I used the PowerShell ISE for this configuration. But you are also very welcome to use Visual Studio Code, just as you wish. Please start with the following steps to begin the deployment (the Hashtags are comments):
#The first two lines have nothing to do with the configuration, but make some space below in the blue part of the ISE
Set-Location C:\Temp
Clear-Host
#Get Credentials to connect
$Credential = Get-Credential
#Create the session
-Credential $Credential -Authentication Basic -AllowRedirection
#Import the session
Import-PSSession $Session -AllowClobber
#Did it work?
Get-UnifiedGroup
#Create new Microsoft 365 Group
New-UnifiedGroup -DisplayName "Study Group" -Alias "0365-Study-Group" `
-EmailAddresses "0365-Study-Group@tomwechsler.xyz" -AccessType Private
#An other Microsoft 365 Group (no space on the Alias Name)
New-UnifiedGroup –DisplayName "M365 Admins" -Alias "M365Admins" -AccessType Public
#Add a member
Add-UnifiedGroupLinks -Identity "M365 Admins" –LinkType Members –Links Tina.Jackson
#To list the Group Members
Get-UnifiedGroupLinks "M365 Admins" –LinkType Member
#To list the Group Owners
Get-UnifiedGroupLinks "M365 Admins" –LinkType Owner
#To add an additional Owner to the Group (this will not work!)
Add-UnifiedGroupLinks –Identity "M365 Admins" –LinkType Owner –Links tim.godin@tomwechsler.xyz
#First, we have to add Tim Godin as a member to the group
Add-UnifiedGroupLinks -Identity "M365 Admins" –LinkType Members –Links Tim.Godin
#Now we can add Tim Godin as an additional Owner to the Group
Add-UnifiedGroupLinks –Identity "M365 Admins" –LinkType Owner –Links tim.godin@tomwechsler.xyz
#To list the Group Owners
Get-UnifiedGroupLinks "M365 Admins" –LinkType Owner
Now you have used the PowerShell to create a Microsoft 365 Group! Congratulations!
#Remove the session (Do not forget to terminate the connection)
Remove-PSSession $Session
I hope this article was useful. Best regards, Tom Wechsler
P.S. All scripts (#PowerShell, Azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler