How can I remove M365 licenses using PowerShell?

0
7
Asked By CreativeFox77 On

Hey everyone! I've been trying to write a script to remove M365 licenses for a few days now, but I keep running into an error with the 'assignlicense' command. I'm really stuck and could use some help. If anyone has insights or suggestions, I'd love to hear them. Thanks! 🙂

4 Answers

Answered By SmartSquirrel55 On

You can simplify things by using Graph commands. For instance, you could run: `$License = Get-MgUserLicenseDetail -UserId ` and then `$result = Set-MgUserLicense -UserId -AddLicenses @() -RemoveLicenses $License.skuid`. Just make sure your Graph PowerShell version is up-to-date to avoid errors!

Answered By HelpfulBumblebee42 On

It would help if you shared what you've tried so far. Also, this article has a lot of commands for removing licenses with PowerShell: [Microsoft Documentation](https://learn.microsoft.com/en-us/microsoft-365/enterprise/remove-licenses-from-user-accounts-with-microsoft-365-powershell?view=o365-worldwide). If you provide the full error message, we might pinpoint the issue faster!

Answered By TechieTurtle89 On

Make sure you're using the latest version of MS Graph PowerShell (2.29.0), as there was a bug that caused issues. Once you upgrade, you can use a script for license management that handles several actions. Check it out here: [O365 Reports](https://o365reports.com/2022/09/08/manage-365-licenses-using-ms-graph-powershell/).

Answered By PracticalPenguin10 On

I highly recommend using AD groups for license assignments. It really streamlines the process of adding and removing licenses when you need to provision or deprovision users. Saves you a ton of manual work!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.