New-AzureADUserAppRoleAssignment

ユーザーをアプリケーション ロールに割り当てます。

構文

New-AzureADUserAppRoleAssignment
   -ObjectId <String>
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   -Id <String>
   -PrincipalId <String>
   -ResourceId <String>
   [<CommonParameters>]

説明

New-AzureADUserAppRoleAssignment コマンドレットは、Azure Active Directory (AD) のアプリケーション ロールにユーザーを割り当てます。

例 1: ロールのないアプリケーションにユーザーを割り当てる

# Get AppId of the app to assign the user to

$appId = Get-AzureADApplication -SearchString "<Your App's display name>"

# Get the user to be added

$user = Get-AzureADUser -searchstring "<Your user's UPN>"

# Get the service principal for the app you want to assign the user to

$servicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$appId'"

# Create the user app role assignment

New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $servicePrincipal.ObjectId -Id ([Guid]::Empty)

このコマンドは、 と を持たないアプリケーションにユーザーを割り当てます。にはロールがありません。

例 2: アプリケーション内の特定のロールにユーザーを割り当てる

$username = "<You user's UPN>"
$appname = "<Your App's display name>"
$spo = Get-AzureADServicePrincipal -Filter "Displayname eq '$appname'"
$user = Get-AzureADUser -ObjectId $username
New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $spo.ObjectId -Id $spo.Approles[1].id

このコマンドレットは、id が $spo で指定されているアプリケーション ロールを指定したユーザーに割り当てます。Approles[1].id。アプリケーションのアプリケーション ロールを取得する方法の詳細については、-Id パラメーターの説明を参照してください。

パラメーター

-Id

割り当てるアプリ ロールの ID。 ロールを持たないアプリケーションの新しいアプリ ロールの割り当てを作成するときに空の guid を指定するか、ユーザーに割り当てるロールの ID を指定します。

アプリケーション オブジェクトの AppRoles プロパティを調べることで、アプリケーションのロールを取得できます。

Get-AzureadApplication -SearchString "Your Application display name" |Approles を選択する |階

このコマンドレットは、アプリケーションで定義されているロールの一覧を返します。

AppRoles : {class AppRole { AllowedMemberTypes: System.Collections.Generic.List1[System.String] Description: <description for this role> DisplayName: <display name for this role> Id: 97e244a2-6ccd-4312-9de6-ecb21884c9f7 IsEnabled: True Value: True Value: <Value> that be transmitted in a token for a token for a token } }

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InformationAction

このコマンドレットが情報イベントに応答する方法を指定します。 このパラメーターの有効値は、次のとおりです。

  • 続行
  • Ignore
  • 照会
  • 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 のユーザーの ID (UPN または ObjectId として) を指定します

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PrincipalId

新しいアプリ ロールが割り当てられているプリンシパルのオブジェクト ID。 ユーザーに新しいロールを割り当てるときに、ユーザーのオブジェクト ID を指定します。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceId

ユーザー ロールが割り当てられているアプリケーションのサービス プリンシパルのオブジェクト ID。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

メモ

Microsoft Graph PowerShell への New-AzureADUserAppRoleAssignment の移行ガイド を参照してください。