powershell - Microsoft graph powershell - 无法添加许可证
问题描述
我正在尝试使用向用户添加许可证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 -β
这是完整的代码:
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。
任何想法,将不胜感激。
谢谢
解决方案
感谢@AdminOfThings 帮助我。
基本上我需要一个东西的格式Hash Table
。我说“thingy”是因为我还不知道哈希表是什么,但这很有效。
Connect-MgGraph
要使用 microsoft graph powershell 在 linux 上为用户添加许可证,请使用以下命令(使用模块登录到 Microsoft graph 后)
Set-MgUserLicense -UserId "Enteremail@emailinquestion.com" -addlicenses @{SkuId = 'ENTER_A_SKUID_HERE'} -RemoveLicenses @()
一个大问题是,当我尝试获取它时,skuid
它会给我名称而不是实际的 SkuID。为此,我需要使用 Windows 计算机来使用 AzureAD 模块来获取 skuid。(注意:AzureAD 模块不能在 Linux 上运行,powershell.core 不支持它)
#Install the module
Install-Module -Name AzureAD
#Connect to the module
Connect-AzureAD
#Use this to get your Skuid, and copy/paste that into your Set-MgUserLicense command
Get-AzureADSubscribedSku | Select -Property Sku*,ConsumedUnits -ExpandProperty PrepaidUnits
推荐阅读
- r - 尝试使用 R 通过 ID 识别连续购买的数量
- python - Python函数在return语句后继续运行?
- html - Flip-Card CSS/HTML:翻转时卡片背面不显示
- azure - Cosmos DB SQL API 查询问题 - 属性名称中的点
- python - 将熊猫数据框中的值乘以固定数字的问题
- python - 如果索引/标题在 Pandas 数据框中包含某些整数,我该如何选择行和列?
- java - java应用的数据库版本升级
- java - ComputationException:java.lang.ArrayIndexOutOfBoundsException:索引 83315 超出长度 71658 的范围
- html - 对滑块应用不透明度
- java - OneToMany 映射在 findById/findAll 期间生成错误的休眠 SQL