In this article, I'll illustrate how to remove all unlicensed users in O365.


Download and install the following modules.

  1. Microsoft Online Service Sign-in Assistant for IT Professionals RTW
  2. Windows Azure Active Directory Module for Windows PowerShell (64-bit version)

Remove Unlicensed Users in Office 365

1) Open PowerShell with elevated privileges.

2) Execute the following command. When you are prompted, enter your O365 global admin account or an account having required privileges.

$credential = Get-Credential

3) Execute the following command to connect to O365.

Connect-MsolService -Credential $credential

4) Execute the following command to remove all unlicensed users.

Get-MsolUser -all | Where-Object {$_.isLicensed -ne "true"}| Remove-MsolUser -Force

5) You can also execute the following command. They both have the same purpose.

Get-MsolUser -All -UnlicensedUsersOnly | Remove-MsolUser -Force

How to Remove Unlicensed Users in Office 365

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *