asked on
Office 365 Removing the license as a bundle
By using the below script, we remove licenses from terminated users.
It is possible to remove licenses from users without having to go to the license service, and we can remove licenses from terminated users as a bundle?
Example:
A user has a F3 license, and the next user has a M3/E3 license. We need to remove all the licenses according to the user assignment.
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:DESKLESSPACK"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:EXCHANGEARCHIVE_ADDON"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:ATP_ENTERPRISE"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:ENTERPRISEPACK"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:SPE_E3"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:POWER_BI_STANDARD"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:FLOW_FREE"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:PROJECTPROFESSIONAL"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:POWERAPPS_VIRAL"}
$Users | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "abc:POWER_BI_PRO"}
ref link: https://learn.microsoft.com/en-us/microsoft-365/enterprise/remove-licenses-from-user-accounts-with-microsoft-365-powershell?view=o365-worldwide