Set-AzureADUserLicense
將 Microsoft 線上服務的授權新增或移除至使用者指派的授權清單。
注意
Set-AzureADUserLicense Cmdlet 已被取代。 瞭解如何使用 Microsoft Graph PowerShell 指派授權。 如需詳細資訊,請參閱指派授權Microsoft 圖形 API。
Syntax
Set-AzureADUserLicense
-ObjectId <String>
-AssignedLicenses <AssignedLicenses>
[-InformationAction <ActionPreference>]
[-InformationVariable <String>]
[<CommonParameters>]
Description
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 Cmdlet 取得使用者,然後將它儲存在 $LicensedUser 變數中。
第二個命令會使用 Get-AzureADUser取得其他使用者,然後將它儲存在$User變數中。
第三個命令會建立 AssignedLicense 類型,然後將它儲存在$License變數中。
第四個命令會將 $License 的 SkuId 屬性設定為與 $LicensedUser 的 SkuId 屬性相同的值。
第五個命令會建立 AssignedLicenses 物件,並將它儲存在$Licenses變數中。
第六個命令會將$License中的授權新增至 $Licenses。
最後一個命令會將 $Licenses 中的授權指派給$User中的使用者。 $Licenses中的授權包含來自第三個和第四個命令的$License。
參數
-AssignedLicenses
指定要指派或移除的授權清單。
Type: | AssignedLicenses |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-InformationAction
指定此 Cmdlet 如何回應資訊事件。 此參數可接受的值為:
- 繼續
- 忽略
- 詢問
- SilentlyContinue
- Stop
- 暫止
Type: | ActionPreference |
Aliases: | infa |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InformationVariable
指定資訊變數。
Type: | String |
Aliases: | iv |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ObjectId
在 Azure AD 中將使用者 (的識別碼指定為 UPN 或 ObjectId) 。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
相關連結
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應