Created
February 8, 2019 21:02
-
-
Save bmorrisondev/f4c4b50df9e460810e374d89f8a1da7d to your computer and use it in GitHub Desktop.
Remove all licenses from a user in Office 365 using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$MsolUser = Get-MsolUser -UserPrincipalName $Username | |
$AssignedLicenses = $MsolUser.licenses.AccountSkuId | |
foreach($License in $AssignedLicenses) { | |
Set-MsolUserLicense -UserPrincipalName $Username -RemoveLicenses $License | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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."