發表文章

目前顯示的是 3月, 2021的文章

透過PowerShell 批量指派授權給使用者 (office 365,Microsoft 365 )

圖片
  如果您管理Office 365後台,則你可能熟悉分配授權給用戶。 對於少數用戶而言,該過程非常簡單 但是如果需要指派授權的數量很龐大 是無法透過UI來指派授權的(會點到手軟) 可以透過以下語法來進行批次指派授權 1.導入msonline模族 import-module MSOnline Connect-MSOLService  //登入帳號(需要admin權限) Get-MsolAccountSkU //取得所有可用授權   Get-MsolUser -UnlicensedUsersOnly  //列出所有未指派授權的帳號 建立一個CSV文件 $License = Import-CSV "C:\users.csv"    $License|foreach{Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses "M365x283554:ENTERPRISEPREMIUM"}  以下是完整語法 import-module MSOnline Connect-MSOLService $users = import-csv "C:\pathtofile\users.csv" -delimiter "," foreach ($user in $users) { $upn=$user.UserPrincipalName $usagelocation=$user.usagelocation $SKU=$user.SKU Set-MsolUser -UserPrincipalName $upn -UsageLocation $usagelocation Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $SKU } footer See also :