This week, I was presented with a question from a partner who was in the middle of the Skype for Business portion of a larger merger and acquisition migration project. The customer had enabled the Skype for Business license for all users in the tenant (including users who hadn’t migrated for other domains and forests), and since neither the hybrid configuration nor DNS were complete, messages and calls were undeliverable. To resolve this, we needed to update the users by removing the Skype for Business license–but the challenge was that users had a variety of SKUs including enterprise voice and conferencing.
Building on my previous Office 365 Licensing script, I came up with this:
$Users = Get-MsolUser -All -DomainName <fqdn> | ? { $_.IsLicensed -eq $True } foreach ($user in $users) { $user.userprincipalname Foreach ($Sku in $user.Licenses) { [array]$DisabledPlans = @() $PlansToDisable = @('MCOSTANDARD','MCOEV','MCOMEETADV','MCOPSTN1') [regex]$PlansToDisableRegEx = '(?i)^(' + (($PlansToDisable |foreach {[regex]::escape($_)}) –join "|") + ')$' [array]$SkuServicePlans = $Sku.ServiceStatus Foreach ($Plan in $SkuServicePlans) { $item = $plan.serviceplan.servicename If ($item -match $PlansToDisableRegex) { $DisabledPlans += $item } } $DisabledPlansOption = New-MsolLicenseOptions -AccountSkuId $Sku.AccountSkuId -DisabledPlans $DisabledPlans Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -LicenseOptions $DisabledPlansOption $DisabledPlansOptions = $null $DisabledPlans = $null } }
This way, regardless of the SKU that existed, we simply set the relevant Skype for Business service plan to Disabled in a new MsolLicenseOption and then applied it to the user.