msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Get-MgDirectoryrole does not return all of the Azure AD roles.

Open MatthewJDavis opened this issue 5 years ago • 2 comments

Graph module version: 1.6 PSVersion: 7.1.3 PSEdition: Core

Hello,

Currently using the Get-MgDirectoryrole Cmdlet only returns 12 Azure AD directory roles.

image

There are more roles as can be seen on the official docs and it would be good to be able to return all of the roles.

Adding the -All parameter produces the following error:

Get-MgDirectoryRole_List: This resource does not support custom page sizes. Please retry without a page size argument.

Thanks,

Matt AB#10139

MatthewJDavis avatar Jul 06 '21 22:07 MatthewJDavis

According to the API reference docs,

When assigning a role using the Azure portal, the role activation step is implicitly done on the admin's behalf. To get the full list of roles that are available in Azure AD, use List directoryRoleTemplates.

you should be using Get-MgDirectoryRoleTemplate | select DisplayName, Id | Sort-Object DisplayName to get a list of roles that are available in Azure AD.

peombwa avatar Jul 07 '21 15:07 peombwa

Thank you for the explanation.

I've created a PR for the docs to include the information in the beta endpoint documentation.

MatthewJDavis avatar Jul 08 '21 00:07 MatthewJDavis