Set-AzureADUserLicense
将Microsoft联机服务的许可证添加到用户分配的许可证列表中。
注释
Set-AzureADUserLicense cmdlet 已弃用。 了解如何 使用 Microsoft Graph PowerShell 分配许可证。 有关详细信息,请参阅 分配许可证 Microsoft Graph API。
语法
Default (默认值)
Set-AzureADUserLicense
-ObjectId <String>
-AssignedLicenses <AssignedLicenses>
[-InformationAction <ActionPreference>]
[-InformationVariable <String>]
[<CommonParameters>]
说明
Set-AzureADUserLicense 将Microsoft联机服务的许可证添加到用户分配的许可证列表中或删除。
示例
示例 1:基于模板用户向用户添加许可证
PS C:\> $LicensedUser = Get-AzureADUser -ObjectId "TemplateUser@contoso.com"
PS C:\> $User = Get-AzureADUser -ObjectId "User@contoso.com"
PS C:\> $License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
PS C:\> $License.SkuId = $LicensedUser.AssignedLicenses.SkuId
PS C:\> $Licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
PS C:\> $Licenses.AddLicenses = $License
PS C:\> Set-AzureADUserLicense -ObjectId $User.ObjectId -AssignedLicenses $Licenses
第一个命令使用 Get-AzureADUser (./Get-AzureADUser.md)cmdlet 获取用户,然后将其存储在 $LicensedUser 变量中。
第二个命令使用 Get-AzureADUser 获取另一个用户,然后将其存储在 $User 变量中。
第三个命令创建 AssignedLicense 类型,然后将其存储在 $License 变量中。
第四个命令将 $License 的 SkuId 属性设置为与 $LicensedUser 的 SkuId 属性相同的值。
第五个命令创建一个 AssignedLicenses 对象,并将其存储在 $Licenses 变量中。
第六个命令将许可证添加到$Licenses$License。
最后一个命令将$Licenses中的许可证分配给$User中的用户。 $Licenses中的许可证包括来自第三和第四个命令的$License。
参数
-AssignedLicenses
指定要分配或删除的许可证列表。
参数属性
| 类型: | AssignedLicenses |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-InformationAction
指定此 cmdlet 如何响应信息事件。 此参数的可接受值为:
- 继续
- 忽略
- 查询
- 静默继续
- 停下
- 暂停
参数属性
| 类型: | ActionPreference |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | infa |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-InformationVariable
指定信息变量。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 四 |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-ObjectId
在 Azure AD 中指定用户的 ID(作为 UPN 或 ObjectId)。
参数属性
| 类型: | String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
(All)
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。