
You have used this command many times before but Set-MgUserLicense Not Working? Why? There could be many reasons why but I am here to tell you of one particular reason in my travels with PowerShell.
Why Use Set-MgUserLicense Not Working
Set-MgUserLicense is very helpful when assigning or un-assigning licenses to several users. The portal does not make it very easy to do this. Sure, if you have a handful of licenses to deal with it is not a problem. But what if you have to work with hundreds or thousands of users at once? PowerShell is the way to go but what if it is not working?
Don’t Use Connect-MsolService to do this
It is now depreciated and you will either get an error message saying so or even worse, it will look like it ran but nothing has happened. If you are trying to re-assign a bunch of licenses from a new provider and you thought it worked but then on Monday your helpdesk lights up like a Christmas Tree, you know it didn’t work and you have a huge problem on your hands.
One big Tip to Prevent Set-MgUserLicense Not Working
Check the version of the Microsoft.Graph Module you are running:
Get-InstalledModule
Version Name Repository Description
------- ---- ---------- -----------
Authentication Module.
2.24.0 Microsoft.Graph.BackupRestore PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.Bookings PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.Calendar PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.ChangeNotifications PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.CloudCommunications PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.Compliance PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.CrossDeviceExper... PSGallery Microsoft Graph PowerShell Cmdlets
2.24.0 Microsoft.Graph.DeviceManagement PSGallery Microsoft Graph PowerShell This is just a snapshot of the many Graph modules but as you can see here, I have version 2.24.0 of the Microsoft.Graph Module installed. The problem occurred when I was at a higher version (name 2.26.0). Downgrading did the trick.
Uninstall-Module -Name Microsoft.Graph -AllVersions
Install-Module Microsoft.Graph -Scope CurrentUser -Repository PSGallery -Force -RequiredVersion 2.24.0Do this and you will solve Set-MgUserLicense Not Working
