How to Create a Office 365 Group using PowerShell?

Requirement: Create New Office 365 Group using PowerShell

How to Create an Office 365 Group in the Admin Center?
Microsoft 365 Groups is a service that enables teams to work together by establishing a single identity and a single set of permissions across Microsoft 365 apps including Outlook, SharePoint, OneNote, etc. As an admin, you can create office 365 groups through Microsoft 365 admin center.
  • Log in to the Microsoft 365 Admin Center site:
  • Expand Groups and Click on Groups in the left navigation.
  • Click on "Add a Group" >> Select "Office 365" under Type. 
  • Provide a name for the group and unique email address for the group. Specify the privacy type for the Office 365 Group.
    powershell to create office 365 group
  • Click on "Select Owner" button and choose the owner to manage the group
  • Click on "Add" to start creating the Office 365 group.
    create an office 365 group
Once we've created a group, all related resources such as Shared mailbox, Calendar, SharePoint Site, etc gets provisioned automatically. Let's see how to create an office 365 group via PowerShell.

How to Create Office 365 Group using PowerShell?
Creating an Office 365 group through PowerShell allows you to have more control over the Group properties. To create an Office 365 Group you need to first establish a remote session to Exchange Online and then use New-UnifiedGroup cmdlet to create an Office 365 Group with PowerShell.

Open Windows PowerShell and run the following script:
#Get Credentials to connect
$Credential = Get-Credential
#Create the session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri `
           -Credential $Credential -Authentication Basic -AllowRedirection
#Import the session
Import-PSSession $Session

#Create New Office 365 Group
New-UnifiedGroup -DisplayName "Consumers Group" -Alias "0365Group-consumers" `
        -EmailAddresses "[email protected]" -AccessType Private

#Remove the session 
Remove-PSSession $Session
This creates a new private group called "Consumers Group" with an email address of "[email protected]"
create office 365 group using powershell
Parameters used in this cmdlets are self-explanatory. Basically, they define properties of the group:
  • DisplayName: The Display name of the group, is the minimum parameter to create a group.
  • Alias: Exchange alias for the group. If you don't supply the value for this parameter, it will be generated.
  • EmailAddresses: The e-mail address of the Group.
  • AccessType: Public or Private.  
There are numerous other parameters that allow you to customize things even further, which are not supported in UI!

Create New Office 365 Group using Azure AD PowerShell Module:
You can create a new group in Office 365 using the Azure Active Directory module as well. Here is an example:
#Connect to Azure AD

#Create new Office 365 group
New-AzureADMSGroup -DisplayName "Accounts Group" -MailNickname "Accounts" -GroupTypes "Unified" -Description "Office 365 Group for Accounts Departmnet" -MailEnabled $True -SecurityEnabled $True
When the "Connect-AzureAD" cmdlet prompts for credentials, Enter your Office 365 Admin account!
create office 365 group using Azure AD powershell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.