我正在尋找一種根據許可證的可用性向用戶添加 E3 或 E1 許可證的方法。
例如:如果不再有 E3 許可證,則添加 E1 許可證
我做什么,我在 2 行上使用“Set-MsolUserLicense”命令。如果第一行出現類似錯誤,則不再可用。然后它轉到第二行并執行第二行。
如果第一行沒有錯誤,然后轉到第二行,然后出現錯誤,則已添加許可證。
所以這就是我的方式:)
任何想法它必須如何?:)
周,男
uj5u.com熱心網友回復:
基于上述共享要求,我們撰寫了以下 powershell 腳本,將檢查當前可用的許可證單元,并相應地為用戶分配 e3 或 e1 的適當許可證。
Connect-MsolService
$userlist={'[email protected]','[email protected]'}
foreach($users in $userlist){
$e3= Get-MsolAccountSku | Where AccountSkuId -Contains microsoft:ENTERPRISEPACK
$e1= Get-MsolAccountSku | Where AccountSkuId -Contains microsoft:STANDARDPACK
if( $e3.ConsumedUnits -le $e3.ActiveUnits){
Write-Host "Need to append e3"
Set-MsolUserLicense -AddLicenses $e3.AccountSkuId -UserPrincipalName $users
}
elseif( $e1.ConsumedUnits -le $e1.ActiveUnits){
Write-Host "Need to append e1"
Set-MsolUserLicense -AddLicenses $e3.AccountSkuId -UserPrincipalName $users
}
else{
Write-host "No active E1 or E3 Linceses available for the current tenant"
}
}
您可以參考此檔案以獲取有關用于許可的產品名稱和服務計劃識別符號的更多資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/367054.html
標籤:电源外壳 azure-powershell 脚本 powershell-1.0 o365-流
上一篇:無法安裝ExchangeOnlinePowerShellV2模塊
下一篇:我錯誤地還原了提交-如何恢復更改
