【问题标题】:O365 - Powershell Plan licensingO365 - Powershell 计划许可
【发布时间】:2017-10-05 16:24:19
【问题描述】:

我正在尝试为已分配许可证的用户授予许可证。例如,我有学生被分配了面向学生的 Office 365 A1 和面向学生的 Office 365 专业增强版。在这些课程中,学生只分配到 Yammer、Office Online for Education 和 SharePoint Plan 1 for EDU。我还需要将 Exchange Online(计划 1)分配给现有学生。但是,当我运行以下脚本时,出现错误: Set-MsolUserLicense :无法分配此许可证,因为它无效。使用 Get-MsolAccountSku cmdlet 检索有效许可证列表。

$Username = "somecompany@microsoft.com" 
$Password = ConvertTo-SecureString "SomePassword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential $Username, 
$Password  

Connect-MsolService -Credential $cred

$StudentUsers = Get-Content -Path "pathfile\users.txt"

Foreach ($user in $StudentUsers){
$LogPath = "logpath\$user.log"

$AccountSkuIdStandard = “CORRECT_SUBSCRIBTION"

$ExchangeOnlineSku = New-MsolLicenseOptions -AccountSkuId    
$AccountSkuIdStandard -DisabledPlans AAD_BASIC_EDU, SCHOOL_DATA_SYNC_P1, 
STREAM_O365_E3, TEAMS1,Deskless, FLOW_O365_P2, POWERAPPS_O365_P2, 
RMS_S_ENTERPRISE, OFFICE_FORMS_PLAN_2,PROJECTWORKMANAGEMENT,SWAY,MCOSTANDARD

#Applies standard license disabling plans
Set-MsolUserLicense -UserPrincipalName $user -AddLicenses 
$AccountSkuIdStandard -LicenseOptions $ExchangeOnlineSku


Add-Content -Path $LogPath "$timestamp Attempting to license $user for O365 
Exchange Online for Students"

Write-Output "Pausing script...."
Start-Sleep 3

Add-Content -Path $LogPath "$user has been licensed for O365 Exchange Online 
for Students"
}

我的理解是因为用户已经被分配了一个许可证,所以他们不能被分配另一个。
当用户已经拥有许可证时,是否可以分配计划(Exchange Online(计划 1))? 我有超过 10,000 个用户需要将此计划/许可证分配给。

感谢您的帮助:)

【问题讨论】:

  • 如果您尝试通过网络管理界面手动将新 SKU 分配给一名学生会怎样?

标签: powershell office365


【解决方案1】:

您需要添加要删除的许可证变量。我想这样就可以了。

Set-MsolUserLicense -UserPrincipalName $user -AddLicenses 
$AccountSkuIdStandard -LicenseOptions $ExchangeOnlineSku -RemoveLicenses $oldLicense

https://blogs.technet.microsoft.com/cloudpfe/2014/01/30/how-to-change-office-365-licenses-in-bulk-respecting-the-license-options/

【讨论】:

    猜你喜欢
    • 2016-12-18
    • 1970-01-01
    • 2012-09-23
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 2015-10-12
    相关资源
    最近更新 更多