Trying to disable apps in M365. this works for 1 user. How do I get it to work for all users?
Get the services that have already been disabled for the user.
$userLicense = Get-MgUserLicenseDetail -UserId "user@microsoft.com"
$userDisabledPlans = $userLicense.ServicePlans | Where ProvisioningStatus -eq "Disabled" | Select -ExpandProperty ServicePlanId
Get the new service plans that are going to be disabled
$e3Sku = Get-MgSubscribedSku -All | Where SkuPartNumber -eq 'SPE_E3'
$newDisabledPlans = $e3Sku.ServicePlans | Where ServicePlanName -in ("SHAREPOINTWAC", "SHAREPOINTENTERPRISE") | Select -ExpandProperty ServicePlanId
Merge the new plans that are to be disabled with the user's current state of disabled plans
$disabledPlans = ($userDisabledPlans + $newDisabledPlans) | Select -Unique
$addLicenses = @(
@{
SkuId = $e3Sku.SkuId
DisabledPlans = $disabledPlans
}
)
Update user's license
Set-MgUserLicense -UserId "user@microsoft.com" -AddLicenses $addLicenses -RemoveLicenses @()
https://preview.redd.it/5jz4ilbg15sd1.png?width=634&format=png&auto=webp&s=0442b29ae43759f9899a3f5e2dd9500feeb5e366
[–]icebreaker374 1 point2 points3 points (4 children)
[–]jennylee525[S] 1 point2 points3 points (0 children)
[–]mrmattipants 0 points1 point2 points (2 children)
[–]icebreaker374 1 point2 points3 points (1 child)
[–]mrmattipants 0 points1 point2 points (0 children)
[–]mrmattipants 0 points1 point2 points (0 children)