次の方法で共有


New-AzureADUserAppRoleAssignment

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

構文

Default (既定)

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 「アプリケーションの表示名」 |[Approles] |フロリダ

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

AppRoles : {class AppRole { AllowedMemberTypes: System.Collections.Generic.List1[System.String] 説明: <このロールの説明> DisplayName: <このロールの表示名> Id: 97e244a2-6ccd-4312-9de6-ecb21884c9f7 IsEnabled: True Value: <このロールのトークンで要求として送信される値> } }

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-InformationAction

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

  • 続ける
  • 不問に付す
  • 問い合わせる
  • 静かに続行
  • 止まれ
  • [中断]

パラメーターのプロパティ

型:ActionPreference
規定値:None
ワイルドカードのサポート:False
DontShow:False
Aliases:infa

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-InformationVariable

情報変数を指定します。

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False
Aliases:iv

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-ObjectId

新しいアプリ ロールが割り当てられる Azure AD のユーザーの ID (UPN または ObjectId) を指定します

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:True
パイプラインからの値:True
プロパティ名別のパイプラインからの値:True
残りの引数からの値:False

-PrincipalId

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

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-ResourceId

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

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:True
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

CommonParameters

このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParametersを参照してください。

メモ

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