The cmdlet Get-MgOrganization cannot be called without the proper permissions. User.Read is the lowest level permission to run the cmdlet. It's not required to specify User.Read when connecting to MS Graph, but the permission needs to be consented to.
By directly specifying this permission in the scopes when connecting, the user will be prompted to grant consent for the permission.
How Has This Been Tested?
Tested by running Connect-MgGraph -Scopes "Application.ReadWrite.All", with no permissions already consented to. Running Get-MgOrganization fails due to insufficient privileges.
Reconnecting with Connect-MgGraph -Scopes "Application.ReadWrite.All", "User.Read" allows the cmdlet Get-MgOrganization to be run succesfully
Reconnecting with Connect-MgGraph with no scopes, the cmdlet Get-MgOrganization still runs as User.Read permission has already been consented to
Screenshots (if appropriate):
Types of changes
What types of changes does your code introduce? Put an x in all the boxes that apply:
[X] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
Go over all the following points, and put an x in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!
[ ] My change requires a change to the documentation.
Description
Related Issue
https://github.com/rubrikinc/polaris-o365-powershell/issues/29
Motivation and Context
The cmdlet
Get-MgOrganization
cannot be called without the proper permissions.User.Read
is the lowest level permission to run the cmdlet. It's not required to specifyUser.Read
when connecting to MS Graph, but the permission needs to be consented to. By directly specifying this permission in the scopes when connecting, the user will be prompted to grant consent for the permission.How Has This Been Tested?
Tested by running
Connect-MgGraph -Scopes "Application.ReadWrite.All"
, with no permissions already consented to. RunningGet-MgOrganization
fails due to insufficient privileges.Reconnecting with
Connect-MgGraph -Scopes "Application.ReadWrite.All", "User.Read"
allows the cmdletGet-MgOrganization
to be run succesfullyReconnecting with
Connect-MgGraph
with no scopes, the cmdletGet-MgOrganization
still runs asUser.Read
permission has already been consented toScreenshots (if appropriate):
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Checklist:
Go over all the following points, and put an
x
in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!