Error "Insufficient privileges to complete the operation" in Powershell - Works ok on Graph Explorer though

Chanderjeet Rai 1 Reputation point
2022-09-29T12:08:58.743+00:00

Hi,

I'm new to using graph and ran a query on the graph explorer which worked ok:

https://graph.microsoft.com/v1.0/groups/xxxxxxxxxxxxxxxx/membersWithLicenseErrors?$select=userPrincipalName

Now, I am trying to the equivalent command in powershell and it fails with this error:

PS C:\Users\User1> Connect-MgGraph
Welcome To Microsoft Graph!

PS C:\Users\User1> Get-MgGroupMemberWithLicenseError -GroupId xxxxxxxxxxxx
Get-MgGroupMemberWithLicenseError : Insufficient privileges to complete the operation.
At line:1 char:1

  • Get-MgGroupMemberWithLicenseError -GroupId xxxxxxxx-ba65-4989-baa8-f1 ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: ({ GroupId = a63...ndProperty = }:<>f__AnonymousType279) [Get-MgGroupMemberWithLicenseError_List4], RestException1
  • FullyQualifiedErrorId : Authorization_RequestDenied,Microsoft.Graph.PowerShell.Cmdlets.GetMgGroupMemberWithLicenseError_List4
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,992 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,621 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Marcel Hadlik 10 Reputation points
    2024-02-26T15:35:59.9466667+00:00

    Hello.

    You can check which permissions you are missing by this command:

    PS> (Find-MgGraphCommand -Command get-MgPolicyAuthorizationPolicy).permissions Policy.Read.All
    Policy.ReadWrite.Authorization

     

    Now connect to M Graph by this command:

    PS> Connect-Graph -scopes "Policy.Read.All"

    2 people found this answer helpful.
    0 comments No comments

  2. Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
    2022-09-29T14:42:36.133+00:00

    Looks like you don't have group.Read.ALL permissions, could you please try to run below command and check your scopes, if you have the required permissions.

    Get-MgContext | select -ExpandProperty Scopes

    If you don't have the required permissions , kindly nun the below command to add the permission

    Connect-MgGraph -Scopes "group.Read.All"

    Hope this will help to fix your issue.

    Thanks


  3. Chanderjeet Rai 1 Reputation point
    2022-09-29T15:00:09.773+00:00

    Yes, seems like I don't have the access. I will confirm once I get the access.


  4. Limitless Technology 44,506 Reputation points
    2022-09-30T08:54:30.707+00:00

    Hello there,

    This problem occurs because the user account that is being used to run the Azure PowerShell cmdlets does not have the correct administrator role.

    To resolve this problem, use one of the following methods:

    -Run the PowerShell cmdlets by using a user account that has the correct administrator role.
    -Promote the problem user account to the correct administrator role.

    For example, you may be required to have a global administrator role in the Azure Active Directory in order to run the cmdlets.

    --------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  5. Kannaiahgari, Saritha 0 Reputation points
    2025-01-31T20:28:09.33+00:00

    Tried running using global admin, still getting error

    Get-MgSubscribedSku : Insufficient privileges to complete the operation.

    Status: 403 (Forbidden)

    ErrorCode: Authorization_RequestDenied

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.