shi*_*jai 4 powershell microsoft-office-365
对于 Office 365 的推出,我们不想让所有用户都可以访问所有可用的应用程序/计划。所以我们只启用了 Exchange 和 Skype。
现在我们要启用 Yammer 和 Office Online,但我们遇到了问题。
$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
}
Run Code Online (Sandbox Code Playgroud)
运行此程序时出现的错误如下:
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
Run Code Online (Sandbox Code Playgroud)
如果我设置了$DisablePlans = $null
,则相同的命令可以正常运行而不会出现问题。
我目前的解决方法是从用户那里删除许可证,然后在启用更新的计划的情况下重新添加它。
我希望有人之前遇到过这个问题,并为此找到了合适的解决方案。
好吧,我是个白痴。我浏览了 GUI 并尝试添加 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
}
}
Run Code Online (Sandbox Code Playgroud)
我能够毫无问题地修改许可证。
归档时间: |
|
查看次数: |
1340 次 |
最近记录: |