Get-EntraUserMembership
ユーザー メンバーシップを取得します。
構文
Default (既定)
Get-EntraUserMembership
-UserId <String>
[-All]
[-Top <Int32>]
[-Property <String[]>]
[<CommonParameters>]
説明
Get-EntraUserMembership コマンドレットは、Microsoft Entra IDのユーザー メンバーシップを取得します。
例
例 1: ユーザー メンバーシップを取得する
Connect-Entra -Scopes 'User.Read'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' |
Select-Object Id, displayName, createdDateTime, '@odata.type' |
Format-Table -AutoSize
Id displayName createdDateTime @odata.type
-- ----------- --------------- -----------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Contoso 2024-10-06T08:49:16Z #microsoft.graph.group
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Contoso marketing 2024-10-07T01:17:28Z #microsoft.graph.group
55ff55ff-aa66-bb77-cc88-99dd99dd99dd Pacific Admin Unit #microsoft.graph.administrativeUnit
この例では、Microsoft Entra IDでユーザー メンバーシップを取得する方法を示します。
例 2: すべてのメンバーシップを取得する
Connect-Entra -Scopes 'User.Read'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' -All |
Select-Object Id, displayName, createdDateTime, '@odata.type' |
Format-Table -AutoSize
Id displayName createdDateTime @odata.type
-- ----------- --------------- -----------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Contoso 2024-10-06T08:49:16Z #microsoft.graph.group
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Contoso marketing 2024-10-07T01:17:28Z #microsoft.graph.group
55ff55ff-aa66-bb77-cc88-99dd99dd99dd Pacific Admin Unit #microsoft.graph.administrativeUnit
この例では、Microsoft Entra IDのすべてのメンバーシップをユーザーに取得する方法を示します。
例 3: 上位 3 つのメンバーシップを取得する
Connect-Entra -Scopes 'User.Read'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' -Top 3 |
Select-Object Id, displayName, createdDateTime, '@odata.type' |
Format-Table -AutoSize
Id displayName createdDateTime @odata.type
-- ----------- --------------- -----------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Contoso 2024-10-06T08:49:16Z #microsoft.graph.group
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Contoso marketing 2024-10-07T01:17:28Z #microsoft.graph.group
55ff55ff-aa66-bb77-cc88-99dd99dd99dd Pacific Admin Unit #microsoft.graph.administrativeUnit
この例では、Microsoft Entra IDで上位 3 つのメンバーシップを取得する方法を示します。
-Limitのエイリアスとして-Topを使用できます。
例 4: Sawyer Miller がメンバーになっているグループを一覧表示する
Connect-Entra -Scopes 'User.Read.All'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' |
Where-Object { $_.'@odata.type' -eq '#microsoft.graph.group' } |
Select-Object Id, displayName, createdDateTime, groupTypes, securityEnabled, visibility, '@odata.type' |
Format-Table -AutoSize
Id displayName createdDateTime groupTypes securityEnabled visibility @odata.type
-- ----------- --------------- ---------- --------------- ---------- -----------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Contoso 2024-10-06T08:49:16Z {Unified} False Public #microsoft.graph.group
11bb11bb-cc22-dd33-ee44-55ff55ff55ff Mark 8 Project Team 2024-10-07T00:43:59Z {Unified} True Public #microsoft.graph.group
22cc22cc-dd33-ee44-ff55-66aa66aa66aa Leadership 2024-10-07T00:43:53Z {Unified} True Private #microsoft.graph.group
この例では、ユーザーが属しているグループを取得します。 同じ結果に Get-EntraUserGroup を使用することもできます。
例 5: ユーザーのディレクトリ ロールを一覧表示する
Connect-Entra -Scopes 'User.Read.All'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' |
Where-Object { $_.'@odata.type' -eq '#microsoft.graph.directoryRole' } |
Select-Object Id, displayName, Description, RoleTemplateId, '@odata.type' |
Format-Table -AutoSize
Id DisplayName Description RoleTemplateId @odata.type
-- ----------- ----------- -------------- -----------
bbbbbbbb-1111-2222-3333-ccccccccccc Helpdesk Administrator Can reset passwords for non-administrators and Helpdesk Administrators. 729827e3-9c14-49f7-bb1b-9608f156bbb8 #microsoft.graph.directoryRole
dddddddd-3333-4444-5555-eeeeeeeeeeee Guest Inviter Can invite guest users independent of the 'members can invite guests' setting. 95e79109-95c0-4d8e-aee3-d01accf2d47b #microsoft.graph.directoryRole
この例では、ユーザーの割り当てられたディレクトリ ロールを一覧表示します。 同じ結果に Get-EntraUserRole を使用することもできます。
例 6: ユーザーの管理単位を一覧表示する
Connect-Entra -Scopes 'User.Read.All'
Get-EntraUserMembership -UserId 'SawyerM@contoso.com' |
Where-Object { $_.'@odata.type' -eq '#microsoft.graph.administrativeUnit' } |
Select-Object Id, displayName, Description, MembershipRule, MembershipType, Visibility |
Format-Table -AutoSize
Id DisplayName Description MembershipRule MembershipType Visibility
-- ----------- ----------- -------------- -------------- ----------
dddddddd-3333-4444-5555-eeeeeeeeeeee Pacific Admin Unit Pacific Administrative Unit
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Engineering Administrative Unit Engineering Admin Unit
この例では、ユーザーの管理単位を一覧表示します。 同じ結果に Get-EntraUserAdministrativeUnit を使用することもできます。
パラメーター
-All
すべてのページを一覧表示します。
パラメーターのプロパティ
| 型: | System.Management.Automation.SwitchParameter |
| 規定値: | False |
| ワイルドカードのサポート: | False |
| DontShow: | False |
パラメーター セット
(All)
| 配置: | Named |
| 必須: | False |
| パイプラインからの値: | False |
| プロパティ名別のパイプラインからの値: | False |
| 残りの引数からの値: | False |
-Property
返されるプロパティを指定します。
パラメーターのプロパティ
| 型: | System.String[] |
| 規定値: | None |
| ワイルドカードのサポート: | False |
| DontShow: | False |
| Aliases: | Select |
パラメーター セット
(All)
| 配置: | Named |
| 必須: | False |
| パイプラインからの値: | False |
| プロパティ名別のパイプラインからの値: | False |
| 残りの引数からの値: | False |
-Top
返されるレコードの最大数を指定します。
パラメーターのプロパティ
| 型: | System.Int32 |
| 規定値: | None |
| ワイルドカードのサポート: | False |
| DontShow: | False |
| Aliases: | 極限 |
パラメーター セット
(All)
| 配置: | Named |
| 必須: | False |
| パイプラインからの値: | True |
| プロパティ名別のパイプラインからの値: | True |
| 残りの引数からの値: | False |
-UserId
Microsoft Entra IDのユーザーの ID (ユーザー プリンシパル名または ObjectId として) を指定します。
パラメーターのプロパティ
| 型: | System.String |
| 規定値: | None |
| ワイルドカードのサポート: | False |
| DontShow: | False |
| Aliases: | オブジェクト識別子, UPN, アイデンティティ, ユーザープリンシパルネーム |
パラメーター セット
(All)
| 配置: | Named |
| 必須: | True |
| パイプラインからの値: | True |
| プロパティ名別のパイプラインからの値: | True |
| 残りの引数からの値: | False |
CommonParameters
このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParametersを参照してください。