使用PowerShell修改O365服务计划

对于Office 365的推出,我们不想让所有的用户访问所有可用的应用程序/计划。 所以我们只启用了Exchange和Skype。

现在我们正处于想让Yammer和Office在线的问题,而且我们遇到了问题。

$LicSKU = "<Hidden>:STANDARDPACK" $ServicePlans = ((Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $LicSKU}).ServiceStatus | Select-Object ServicePlan -ExpandProperty ServicePlan).ServiceName $EnabledPlans = 'EXCHANGE_S_STANDARD','YAMMER_ENTERPRISE', 'SHAREPOINTWAC', 'MCOSTANDARD' $DisabledPlans = @() foreach($Plan in $ServicePlans) { if($EnabledPlans -notcontains $Plan) { $DisabledPlans += $Plan } } $LicOption = New-MsolLicenseOptions -AccountSkuId $LicSKU -DisabledPlans $DisabledPlans try { $UserLicense = @{ UserPrincipalName = $UserPrincipalName AddLicenses = $LicSKU LicenseOptions = $LicOption } Set-MsolUserLicense @UserLicense -ErrorAction Stop } catch [Microsoft.Online.Administration.Automation.MicrosoftOnlineException] { $UserLicense.Remove('AddLicenses') Set-MsolUserLicense @UserLicense -ErrorAction Stop } 

我运行时得到的错误如下:

 Set-MsolUserLicense : Unable to assign this license. + Set-MsolUserLicense @UserLicense -ErrorAction Stop + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], MicrosoftOnlineException + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidLicenseConfigurationException,Microsof t.Online.Administration.Automation.SetUserLicense 

如果我设置$DisablePlans = $null ,那么相同的命令运行良好没有问题。

我目前的工作是从用户中删除许可证,然后将其添加到启用更新的计划中。

我希望有人遇到这个问题之前,find一个适当的解决scheme。

那么我是一个白痴。 我通过graphics用户界面,试图添加Office Online,它抱怨说,它也需要Sharepoint。

所以当我更新代码

 $ServicePlans = ((Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $LicSKU}).ServiceStatus | Select-Object ServicePlan -ExpandProperty ServicePlan).ServiceName $EnabledPlans = 'EXCHANGE_S_STANDARD','YAMMER_ENTERPRISE', 'MCOSTANDARD', 'SHAREPOINTSTANDARD', 'SHAREPOINTWAC' $DisabledPlans = @() foreach($Plan in $ServicePlans) { if($EnabledPlans -notcontains $Plan) { $DisabledPlans += $Plan } } 

我能够修改许可没有问题。

您也可以尝试使用Azure门户进行许可证pipe理(Azure Active Directory – 许可证)。 它支持将许可分配给用户组。 所以你只需要为包含所有用户的组进行一次赋值。 包括新用户时,你永远不需要做任何分配。