Office 365, PowerShell

Flow and Azure automation working in harmony

Hi all, please see my latest blog post on Flow & Azure automation working in harmony. It’s truly awesome.

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

PowerShell, SharePoint, SharePoint 2007, SharePoint 2010, SharePoint 2013

Find your Application Pool username and password

In IIS when you select Application Pools, IIS will display all the application pools with their names and the Account associated to the Application Pool for those Engineers out there wanting to retrieve the application pool service accounts password follow these easy instructions… easy as 123

1. Open up Powershell as Administrator

2. type cd C:\Windows\System32\inetsrv

3. Type the following:

.\appcmd.exe list apppool “Application Pool Name” /text:*

be sure to change “Application Pool Name” to your Application pool you are after

This will give you a long list of output, scroll down a little and you will see the Password field.

Enjoy 🙂