有篇文章我们讨论了如何通过导入 .csv 表格批量地分配 license,今天这篇文章我们再讨论如何给国际版 Microsoft 365 用户下掉 license。

一、给一位用户下掉 license

如果需要给一位用户下掉 license,只需简单地运行 PowerShell 命令即可。

例如,我需要给一位叫 “User 001” 的用户下掉他的 Microsoft 365 E5 开发板 license,那么可以执行以下的步骤:

1. 连接到 MsOnline PowerShell:

$Msolcred = Get-Credential
Connect-MsolService -Credential $Msolcred

2. 运行以下命令:

Set-MsolUserLicense -UserPrincipalName user002@irabit.org -RemoveLicenses itoolsoft:DEVELOPERPACK_E5

这个时候检查他的 license,就会发现他的 license 已经被下掉了。

二、给多位用户下掉 license

如果需要给多位用户下掉 license,那么可以参考我们上一篇文章的思路,只是我们需要将里面的 .ps1 脚本替换为以下的内容(记得按需更改 usagelocation 和 SKU 的值):

#Session to Microsoft Azure AD (Use if Azure AD session inactive)
$msolcred = get-credential
connect-msolservice -credential $msolcred
	 
#Import data from CSV file
    $users = import-csv ".\AssignLicense.csv"
#Assign License & Location based on UserPrincipalName from the CSV.   
    foreach ($user in $users)
    {
        $upn=$user.UserPrincipalName
        $usagelocation= "CN"  #Ensure to enter the correct location based on your user/organization location
        $SKU= "itoolsoft:DEVELOPERPACK_E5" #Ensure to enter the correct AccountSkuID based on your SkuID
        Set-MsolUser -UserPrincipalName $upn -UsageLocation $usagelocation
        Set-MsolUserLicense -UserPrincipalName $upn -RemoveLicenses $SKU
        Write-Host "License Assigned to UPN:"$upn #Return which UserPrincipalName was successfully assigned with the license
    } 

好了。