Cannot Import Microsoft Graph Modules: Import-Module : Function Invoke-MgGraphGroupDrive cannot be created because function capacity 4096 has been exceeded for this scope.

Bühler Gabriel 81 Reputation points
2024-01-29T16:23:23.3133333+00:00

Hello Everyone

I am trying to use Microsoft Graph, but Powershell completely freezes up when I try to import the module with "Import-Module Microsoft.Graph". It also freezes up when I try to use specific modules like "Microsoft.Graph.Files" or I get the error " Import-Module : Function Invoke-MgGraphGroupDrive cannot be created because function capacity 4096 has been exceeded for this scope."

I already tried the following steps:

  1. Uninstalled and reinstalled Powershell
  2. Removed all Modules and reinstalled them
  3. Installed the newest Version of .NET
  4. Tried it on a different device

Do you might know how I could further troubleshoot this?

Thank you for your help.

Kind regards,

Gabriel

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,273 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Oliveira, Robenildo 40 Reputation points
    2024-06-13T13:03:06.97+00:00

    My step by step to troubleshoot:

    Required to run the powershell script

    Install-Module -Name Microsoft.Graph -AllowClobber -Scope CurrentUser -Force

    Update-Module -Name Microsoft.Graph

    $maximumfunctioncount = '32768'

    Import-Module -Name Microsoft.Graph

    Thank you for your time in helping.

    5 people found this answer helpful.

  2. Carolyne-3676 211 Reputation points
    2024-02-14T11:03:11.27+00:00

    The error message indicates that the function capacity has been exceeded for the current scope. It happens if you have imported too many modules in your PowerShell session. A couple of steps to help you troubleshoot:

    1. Ensure you have installed the module using Install-Module Microsoft.Graph -Scope YourPrefferedScope(CurrentUser/AllUsers) doc link here then verify if installed using Get-InstalledModule Microsoft.Graph
    2. Please increase the $maximumfunctioncount to the max 32768 and try and load the Graph Modules that you need- Reference for existing modules . Including necessary modules will free up capacity.
    3. You can run the Import-Module Microsoft.Graph to allow for the cmdlets to be available for the PowerShell session.
    1 person found this answer helpful.

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.