Skip to content
theDXT
  • Home
  • IT
  • Scripts
  • GitHub
  • LinkedIn
  • X (Twitter)
  • Search Icon
Swap Microsoft 365 Licenses with Microsoft Graph

Swap Microsoft 365 Licenses with Microsoft Graph

November 25, 2023

A few years ago I wrote a post about how to Swap Office 365 Licenses. Microsoft has deprecated the cmdlets that were used in that post specifically Set-MsolUserLicense and has replaced them with Microsoft Graph cmdlets specifically Set-MgUserLicense.

In this post, I will show step-by-step how to swap Microsoft 365 licenses using Microsoft Graph and PowerShell.

Prerequisites

  • Microsoft Graph installed and configured. If you don’t know how to do that. Here’s my blog post about the Microsoft 365 Setup for Microsoft Graph PowerShell SDK

The Process

We need a few more permissions than the default permissions for Microsoft Graph.

  • Run the following command to connect Microsoft Graph to your Microsoft 365 tenant with the necessary permissions Connect-MgGraph -Scopes User.ReadWrite.All, Organization.Read.All

Now let’s find out what SKUs we have to work with.

  • Run the following command to get the list of SKUs in your Microsoft 365 tenant Get-MgSubscribedSku -All | select SkuPartNumber

If you aren’t sure what product the SKU correlates to Microsoft has made a decoder ring, you can find that here.

Now for the license swap part, I’ve created a PowerShell script to do it.

You can find the Script on my GitHub https://github.com/thedxt/Microsoft-365/tree/main#lic-swap-ms-graphps1

Change the variables for remove_LIC and add_LIC to match your needs.

The script will find all the users that have the SKU for the license you want to remove.

From the results, it will run a for-each loop that removes the license and outputs details on the removed license along with the UPN (User Principal Name) of the user it was removed from.

The script will then move on to adding the license and will output details on the added license and the UPN of the user it was added to.

The magic that makes the script work is the command Set-MgUserLicense.

That’s all it takes to switch Microsoft 365 licenses using Microsoft Graph.

If you want to read more about the Set-MgUserLicense cmdlet you can do so by reading the Microsoft documentation here.

Related posts:

Default ThumbnailSwap Office 365 Licences Microsoft 365 Setup Microsoft Graph PowerShell SDK Control Microsoft 365 Group Creation Microsoft 365 Enable Organization Customization

IT, Scripts
How To, Microsoft, Microsoft 365, Microsoft Graph, Office 365, PowerShell, Script

Post navigation

PREVIOUS
Windows Verbose Status
NEXT
Microsoft Configuration Manager Backup

2 thoughts on “Swap Microsoft 365 Licenses with Microsoft Graph”

  1. Jerry says:
    February 29, 2024 at 4:50 pm

    Life saver!

    Reply
    1. Daniel Keer says:
      March 2, 2024 at 10:09 am

      Glad it helped.

      Reply

Leave a Reply Cancel reply

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

About Me

Daniel Keer

Project Lead, Senior Consultant at Digitally Accurate Inc.

Awards and Certificates
VMware vExpert ⭐⭐⭐
Omnissa Tech Insider ⭐⭐⭐

Consulting

Stuck on something? Reach out to Digitally Accurate Inc. and we can provide expert IT consulting to help you move forward.

  • Veeam Backup & Replication 13 Windows Install
  • Enable Windows 10 Extended Security Updates
  • slmgr.vbs
  • CyberChef
  • Install or Upgrade Duo Authentication for Windows Logon
© 2026   Copyright. All Rights Reserved.