A couple of months ago the AzureADPreview module was released. The first cmdlet that I experimented with was Set-AzureADUserLicense. And I couldn’t get it to work. There were no working examples showing how to use it, so I gave up and used the Azure AD Graph API directly instead.
Since then the AzureADPreview has gone through a number of revisions and I’ve been messing around with it a little more with each update. The Set-AzureADUserLicense cmdlet has been my litmus test to its functionality. Now that I have both removing and assigning Office 365 licenses working using the Set-AzureADUserLicense cmdlet I’ll save others the pain of working it out and give a couple of working examples.
If like me you have been experimenting with the AzureADPreview module you’ll need to force the install of the newest one. And for whatever reason I was getting an error informing me that it wasn’t signed. As I’m messing around in my development environment sandpit I was confident enough to skip the publisher check. I expect the module to be signed when it is no longer in ‘Preview’.
Install-Module -Name AzureADPreview -MinimumVersion 2.0.0.7 -Force -SkipPublisherCheck Import-Module AzureADPreview -RequiredVersion 2.0.0.7
Removing an Office365 license with Set-AzureADUserLicense looks something like this.
What if there are multiple licenses? It’s a very similar concept by just looping through each one to remove and add them to the remove collection.
Now that we have the removal of licenses sorted, how about adding licenses?
Assigning a license with Set-AzureADUserLicense looks something like this;
Moving forward the release version of this AzureAD Preview PowerShell Module will replace the older MSOL Module as I wrote about here. If you’re writing new scripts it’s a good time to start using the new modules.
Follow Darren on Twitter @darrenjrobinson
Today, I’m super excited to finally announce the Beta release of EntraPulse Lite – a…
I'm excited to share some significant authentication enhancements I've contributed to the Lokka MCP Server…
Last month I had the pleasure of speaking at the Sydney event for Global Azure.…
Model Context Protocol (MCP) is a powerful framework that extends AI clients like Claude and…
I've just completed participating in the Azure AI Developer Hackathon that was looking to provide…
Updated: July 2025 v1.0.2 Fixes issue setting D365SalesGlobals enabling session management for D365 Sales API…
This website uses cookies.
View Comments