How to create Office 365 Group based on user's assigned license

Introduction

This script is used to create Office 365 Group based on user's assigned license.

Scenarios

This script is used to create Office 365 Group based on user's assigned license.


Script

You can use this script in the following way.

1. Open Windows PowerShell.

2. Type the command< Script Path> at the Windows PowerShell Console.

For example, type C:\Script\ GroupOnlicenseType.ps1 

Here are some code snippets for your reference.

PowerShell
Edit|Remove
$GroupMember = Get-MsolUser | Where-Object {$_.Licenses.AccountSKUid -eq $License} 
  
$GroupID = New-MsolGroup -Name $GroupName | select ObjectId 
    
Foreach($mem in GroupMember) 
{ 
     Add-MsolGroupMember -GroupObjectId GroupID -GroupMemberObjectId $mem.ObjectId.Guid  
} 
}

Examples

       Example1: Create a group named “Enterprise Group” which will contain the SKU ‘Tenant: ENTERPRISEPACK’

GroupOnlicenseType.ps1 – License License – GroupName “Enterprise Group”

Prerequisites

Exchange Online
Windows PowerShell 2.0