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?
As an admin, you can create office 365 groups through Microsoft 365 admin center.
  • Login to the Microsoft 365 Admin Center site: https://admin.microsoft.com
  • 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 mail box, Calendar, SharePoint Site, etc gets provisioned automatically. Let's see how to create office 365 group via PowerShell.

How to Create Office 365 Group using PowerShell?
Creating Office 365 group through PowerShell allows you to have more control over the Group properties. To create a 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 https://outlook.office365.com/powershell-liveid/ `
           -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 "ConsumersGroup@TheCrescentTech.com" -AccessType Private

#Remove the session 
Remove-PSSession $Session
This creates a new private group called "Consumers Group" with an email address of "ConsumersGroup@TheCrescentTech.com"
create office 365 group using powershell
Parameters used in this cmdlets are self-explanatory. Basically they define properties of the group:
  • DisplayName: 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 new group in Office 365 using Azure Active Directory module as well. Here is an example:
#Connect to Azure AD
Connect-AzureAD

#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
How to Create a Office 365 Group using PowerShell? How to Create a Office 365 Group using PowerShell? Reviewed by Salaudeen Rajack on May 21, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.