Office 365, PowerShell

Adding a user to a group in office 365 using PowerShell

This article will walk you through how to add your Office 365 Users to an Office 365 Group.

There are a few pre-requisites to do this. One of which is having ‘Windows Azure Active Directory Module’ installed on your machine. Second, that you are an Administrator.


I have 10 users who I would like each to be added to an Office 365 Group. I’m a little too lazy to add one by one so I’ll look to do this with Powershell.

So first up I’ll need to create the group to add my 10 test users into.

From the Office 365 admin centre click Groups, click the + for this demo. I’ve created a group called  ‘Test Security Group’ and as you can see from the screenshot below no users have been added.



Below is a screenshot of the users I will be adding to the security group.











OK so now we have our users & group we need to open up the Windows Azure Active Directory Module for Windows PowerShell

Once the powershell window is opened you will need to connect to your tenant. To do this type-


You will then be prompted to type in a tenant administrators username/password combination to proceed.

Once authenticated we need to get the ID of the group. Easy.

$groupid = Get-MsolGroup | Where-Object {$_.DisplayName -eq “Test Security Group”}

This line is finding a group that matches the Group Display Name of “Test Security Group” and putting it into the $groupid variable.

We can now leave the group for now. It’s time to start getting the users id’s in order to add to this group.

As I have a large number of users in my directory I conveniently named the users test1 to test10. Because of this I will get these users and put them to a variable so I can extract the information needed to add these users to a group.

$users = Get-MsolUser | Where-Object {$_.DisplayName -like ‘*Test*’}
It’s important to note that I am only filtering the users as I don’t want to add all users in the domain to this Active Directory. You can add and filter as you please.

It’s now time to add the users to the group. We are going to use the $users variable and run a foreach loop which will iterate through each user and grab it’s ObjectId and add to the security group.

$users | foreach {Add-MsolGroupMember -GroupObjectId $groupid.ObjectId -GroupMemberObjectId $_.ObjectId -GroupMemberType User} AddingUser

Depending on how many users you’re adding in bulk it may take a couple of minutes so be patient. Once it run’s, check back to your group and see if the users are added.



You can download the full script here


SharePoint Online – enabling latest features

As Office 365 but specifically in this case SharePoint Online continues to develop and grow you may be missing out on the latest updates;

Microsoft released a configuration change  a little while back that allows you to turn on ‘Preview Features’, Preview Features are the latest changes that haven’t been released to all tenants yet so it really in my opinion should be used in dev environments only to test and release changes before arriving at a production environment

So How do I enable the preview features?

Easy, navigate to your admin tenant (

Click Settings, scroll most of the page down and you will see a section called ‘Preview Features’ .

Enable the feature and click OK

Once done the latest Preview features should be available to you.

Learn more about Preview Features here