【发布时间】:2021-06-19 22:52:04
【问题描述】:
我正在尝试使用 Set-MgUserLicense 向用户添加许可证,但我收到错误消息:Set-MgUserLicense: Cannot process argument transformation on parameter 'AddLicenses'.
主要问题是我需要帮助以他们想要的正确方式放置许可证 sku。但是我无法在线或从文档中找到示例:https://docs.microsoft.com/en-us/powershell/module/microsoft.graph.users.actions/set-mguserlicense?view=graph-powershell-beta
这里是完整的代码:
Set-MgUserLicense -UserId "testuser@testuser.com" -addLicenses [SkuId:reseller-account:ENTERPRISEPACK] -RemoveLicenses @()
这是完整的错误:
Set-MgUserLicense: Cannot process argument transformation on parameter 'AddLicenses'.
Cannot convert value "[SkuId:reseller-account:ENTERPRISEPACK]" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphAssignedLicense[]".
Error: "Cannot convert the "[SkuId:reseller-account:ENTERPRISEPACK]" value of type "System.String" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphAssignedLicense"."
我也试过:
reseller-account:ENTERPRISEPACK
SkuId:reseller-account:ENTERPRISEPACK
两者都给出相同类型的错误。
我通过在 Windows 计算机上使用 MSOnline 获得了 SKU。
AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ -------------
reseller-account:ENTERPRISEPACK 31 0 30
reseller-account:FLOW_FREE 10000 0 5
reseller-account:CCIBOTS_PRIVPREV_VIRAL 10000 0 1
reseller-account:POWER_BI_STANDARD 1000000 0 2
reseller-account:TEAMS_EXPLORATORY 100 0 2
reseller-account:MCOMEETADV 1 0 1
我会使用 MSOnline 向用户添加许可证,但这不适用于 powershell.core,这意味着它不适用于 linux。
任何想法都将不胜感激。
谢谢
【问题讨论】:
-
使用哈希表的文档提及。所以也许试试
-addlicenses @{SkuId = 'reseller-account:ENTERPRISEPACK'} -
老兄,你完全救了我的皮肤。
reseller-account:ENTERPRISEPACK不起作用,但“哈希表的东西”的格式确实起作用。当我第一次尝试时,它说reseller-account:ENTERPRISEPACK不是许可证。所以我进入了一台 Windows 计算机,并使用 azureAD 模块提取了确切的 skuid,这个:Get-AzureADSubscribedSku | Select -Property Sku*,ConsumedUnits -ExpandProperty PrepaidUnits然后我用它来获取正确的 Skuid。我会留下一个答案。
标签: powershell