Add Bulk Users to Office 365 Group with PowerShell

As you know Microsoft is targeting Office 365 Group as base service for many of cloud services like Planner, Teams and etc. So now a days every admins getting frequent request to add new on-board users to Office 365 group, we can easily achieve this task with Exchange Online powershell cmdlet Add-UnifiedGroupLinks.

Before proceed run the below commands to connect Exchange Online Powershell session.

$365Logon = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection
Import-PSSession $Session

Run the below command to add single user into Office 365 group.

Add-UnifiedGroupLinks –Identity "O365Group" –LinkType Members  –Links [email protected]

We have to set the parameter LinkType as Members to add user as member and other valid values are Owners and Subscribers.

The parameter Links accept multiple values, we need to provide users as comma (“,”) separated values to add multiple members (ex: [email protected],[email protected]….). If the user names contain spaces or otherwise require quotation marks (ex: “username 1″,”username 2”,…).

Add multiple members to O365 group:

Add-UnifiedGroupLinks –Identity "O365Group" –LinkType Members  –Links "[email protected]","[email protected]"

Add Bulk Users to Office 365 Group from CSV

For bulk import process the CSV file is the best choice of all time, you can use the below powershell commands to add bulk members to an office 365 group by importing user identities from csv file. Consider the csv file “members.csv” (Download sample CSV) that includes the column header “member” which holds the user identity values in each row of the csv file.

Import-CSV "C:\members.csv" | ForEach-Object {
Add-UnifiedGroupLinks –Identity "O365Group" –LinkType Members  –Links $_.member
}

Find and list members of unified group:

Once we added user as member in O365 group, we can use Get-UnifiedGroupLinks cmdlet to get members. The below command lists all members of given group.

Get-UnifiedGroupLinks –Identity "O365Group" –LinkType Members -ResultSize Unlimited
Advertisement

7 thoughts on “Add Bulk Users to Office 365 Group with PowerShell”

  1. Getting this error when pulling from a csv:

    Cannot bind argument to parameter 'Links' because it is null.
    + CategoryInfo : InvalidData: (:) [Add-UnifiedGroupLinks], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Add-UnifiedGroupLinks
    + PSComputerName : outlook.office365.com

    Reply

Leave a Comment