# Az Module - List users with role assignment

**URL:** <https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244>\
**Category:** PowerShell Help\
**Created:** [March 22, 2019, 6:34am UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244 "2019-03-22T06:34:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anelliaf](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@anelliaf](https://forums.powershell.org/u/anelliaf)\
**Post date:** [March 22, 2019, 6:34am UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244/1 "2019-03-22T06:34:10Z")

</div>

Hello,

I’m using the Azure AZ module to try and list all users assigned to a specific role.

I have one line of code that will list all the information about a role but it’s not formatted to my desire:

```
Get-AzRoleAssignment -ResourceGroupName <rg_name> | Where-Object RoleDefinitionName -EQ 'owner'
```

I’d only like to see a few fields/objects, i.e) DisplayName, RoleDefinitionName, etc.

When I add a “pipe” with:

```
Select-Object DisplayName, RoleAssignmentId
```

, but nothing is returned.

Thanks,

Frank

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [March 22, 2019, 7:06am UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244/2 "2019-03-22T07:06:18Z")

</div>

Works as expected for me.

---

<div class="post-metadata">

**Author:** ![anelliaf](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@anelliaf](https://forums.powershell.org/u/anelliaf)\
**Post date:** [March 22, 2019, 10:01am UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244/3 "2019-03-22T10:01:52Z")

</div>

Haha, you’re right! I’m glad you said that because it made me take another look at it and the piping was incorrect. I had the following:

```
Get-AzRoleAssignment -ResourceGroupName use2-uphs-dev-dac-sqldw-rg | Select-Object DisplayName, RoleAssignmentId | Where-Object RoleDefinitionName -EQ 'owner'
```

but it should be this:

```
Get-AzRoleAssignment -ResourceGroupName use2-uphs-dev-dac-sqldw-rg | Where-Object RoleDefinitionName -EQ 'owner' | Select-Object DisplayName, RoleAssignmentId
```

Thanks for getting back to me!

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [March 22, 2019, 10:53am UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244/4 "2019-03-22T10:53:37Z")

</div>

Ah ok yes … with a Select-Object you limit the properties you pass down the pipeline to what you provide. If you do a Select-Object DisplayName, you will not be able to do a Where-Object on the owner property. 😉

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/az-module-list-users-with-role-assignment/12244/5 "2024-05-16T20:33:07Z")

</div>

Closed on May 16, 2024, 8:33pm UTC


