A couple of months ago the AzureADPreview module was released. The first cmdlet that I experimented with was Set-AzureADUserLicense. And it didn’t work, there was no working examples and I gave up and used GraphAPI instead.
Since then the AzureADPreview has gone through a number of revisions and I’ve been messing around a little with each update. The Set-AzureADUserLicense cmdlet has been my litmus test. Now that I have both removing and assigning Office 365 licenses working 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 dev sandpit I skipped the publisher check.
Install-Module -Name AzureADPreview -MinimumVersion 126.96.36.199 -Force -SkipPublisherCheck
Import-Module AzureADPreview –RequiredVersion 188.8.131.52
Removing an Office 365 License from a User
Removing a license with Set-AzureADUserLicense looks something like this.
What if there are multiple licenses ? Similar concept but just looping through each one to remove.
Assigning an Office 365 License to a User
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 this AzureAD 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