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
Olaf
March 22, 2019, 7:06am
2
Works as expected for me.
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!
Olaf
March 22, 2019, 10:53am
4
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.