2017-10-05 362 views
1

我试图使用PowerShell而不是在线门户将许可证分配给(超过60个)用户帐户。在下面我已经指定了管理员帐户(全部是[email protected])作为测试数据集。我一直在这个TechNet文章如下: https://technet.microsoft.com/en-us/library/dn771770.aspx向用户批量分配Office 365许可证

$AdminUnE3 = Get-MsolUser -All -UnlicensedUsersOnly -Searchstring "a-"; $AdminUnE3 | foreach {Set-MsolUserLicense -AddLicenses "reseller-account:SPE_3"} 

但是我提示以下:

cmdlet Set-MsolUserLicense at command pipeline position 1 
Supply values for the following parameters 
ObjectId: 

回答

1

您需要在OBJECTID或者你是哪个用户的UPN传递分配许可证,是这样的:

foreach {Set-MsolUserLicense $_.ObjectId -AddLicenses "reseller-account:SPE_3"} 

用户对象可能没有一个OBJECTID属性,您可以使用UPN也:

Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName (or something like that) -AddLicenses "xxxxx" 
+0

附加说明:通常,对于新帐户,使用位置未定义。这会给你一个错误提示,所以当你申请许可证。您将必须设置使用位置,然后在这些情况下添加许可证。 I.E. Set-MsolUser -UserPrincipalName $ User -UsageLocation“US”(当然,您应该将实际使用位置对应于用户的位置。 –