はじめまして。
特定のサービスプランをユーザ毎に一律無効にされたい場合は、以下流れでコマンドを実行する方法が一案です。
- MS graphにアクセス
Connect-MgGraph -Scopes User.ReadWrite.All, Organization.Read.All
- 外したいライセンスとサービスプランのSkuIDを確認
・ライセンス
Get-MgSubscribedSku | Select -Property Sku*, ConsumedUnits -ExpandProperty PrepaidUnits | Format-List
→ SkuID = xxxxx が表示
・サービスプラン(以下 Microsoft 365 Apps for Enterprise が 先頭行に表示された場合)
Get-MgSubscribedSku | Select SkuPartNumber
SkuPartNumber
-------------
OFFICESUBSCRIPTION
・・・・
$licenses = Get-MgSubscribedSku
$licenses[0].ServicePlans
→ SkuID = yyyyy が表示
- 無効にするサービスプランを指定
$License1 = New-Object -TypeName Microsoft.Graph.PowerShell.Models.MicrosoftGraphAssignedLicense -Property @{SkuId = "xxxxx"; DisabledPlans = @("yyyyy")}
4, ユーザ毎に無効化
Set-MgUserLicense -UserId "******@aaa.com" -AddLicenses @($License1) -RemoveLicenses @()
Set-MgUserLicense -UserId "******@aaa.com" -AddLicenses @($License1) -RemoveLicenses @()
Set-MgUserLicense -UserId "******@aaa.com" -AddLicenses @($License1) -RemoveLicenses @()
・・・
※参考情報
PowerShell を使用して Microsoft 365 ライセンスをユーザー アカウントに割り当てる
Microsoft Graph PowerShell SDK を使用したライセンス管理操作の紹介operating-license-with-microsoft-graph/#idx4-2