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
A few weeks back the Microsoft AI Tour was in Sydney Australia. There was a…
If you're anything like me you always have PowerShell open, and often both PowerShell and…
Decentralised Identity is a technology I'm passionate about and have written many posts and tools…
Over two years ago I authored a PowerShell Module that enabled the automation of 1Password.…
Buried in my PowerShell Snippets Vol 4 post from 2021 is the PowerShell script and…
Short post on how to recovery from "The Windows Subsystem for Linux instance has terminated"…
This website uses cookies.
View Comments