Skip to content

Instantly share code, notes, and snippets.

@bmorrisondev
Created February 8, 2019 21:02
Show Gist options
  • Save bmorrisondev/f4c4b50df9e460810e374d89f8a1da7d to your computer and use it in GitHub Desktop.
Save bmorrisondev/f4c4b50df9e460810e374d89f8a1da7d to your computer and use it in GitHub Desktop.
Remove all licenses from a user in Office 365 using PowerShell
$MsolUser = Get-MsolUser -UserPrincipalName $Username
$AssignedLicenses = $MsolUser.licenses.AccountSkuId
foreach($License in $AssignedLicenses) {
Set-MsolUserLicense -UserPrincipalName $Username -RemoveLicenses $License
}
@IWSITJS
Copy link

IWSITJS commented Mar 14, 2024

Dropping a note for future:
The ability to modify licensing via legacy PowerShell modules is no longer supported.
"As previously communicated, the legacy licensing assignment PowerShell cmdlets (Set-AzureADUserLicense, Set-MsolUserLicense, -LicenseAssignment or -LicenseOptions parameters of New-MsolUser) and Azure AD Graph API (assignLicense) are retired."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment