Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 向用户批量分配Office 365许可证_Powershell_Office365 - Fatal编程技术网

Powershell 向用户批量分配Office 365许可证

Powershell 向用户批量分配Office 365许可证,powershell,office365,Powershell,Office365,我正在尝试使用powershell而不是在线门户为(超过60个)用户帐户分配许可证。在下面我指定了管理员帐户(所有帐户都是a-firstname)。lastname@domain.co.uk)作为测试数据集。我一直在关注这篇technet文章: 但是,我收到以下提示: cmdlet Set-MsolUserLicense at command pipeline position 1 Supply values for the following parameters ObjectId: 您需

我正在尝试使用powershell而不是在线门户为(超过60个)用户帐户分配许可证。在下面我指定了管理员帐户(所有帐户都是a-firstname)。lastname@domain.co.uk)作为测试数据集。我一直在关注这篇technet文章:

但是,我收到以下提示:

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

您需要传入要向其分配许可证的用户的objectId或UPN,如下所示:

foreach {Set-MsolUserLicense $_.ObjectId -AddLicenses "reseller-account:SPE_3"}
用户对象可能没有objectid属性,您也可以使用UPN:

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

最好的方法是首先为所有用户分配-UsageLocation,然后通过授权来继续;分配没有使用位置的许可证会导致错误。

附加说明:通常,对于新帐户,使用位置未定义。这将在应用许可证时显示一个错误。在这种情况下,您必须设置使用位置,然后添加许可证。例如,设置MsolUser-UserPrincipalName$User-UsageLocation“US”(当然,您应该将实际使用位置与用户的位置相对应)。
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName (or something like that) -AddLicenses "xxxxx"