I have tried with PowerShell-7.4.1-win-x64 and I've got the same error.
PowerShell import module function cannot import more than 4096 modules and Microsoft.Graph has 4096+ modules, how to solve this?
I am trying to install Microsoft.Graph modules with PowerShell on an offline Windows 2019 server.
I have copied the 39 modules of Microsoft.graph from my Internet-connected pc to C:\Program Files\WindowsPowerShell\Modules\ on my offline server.
then I try to import those modules with the following command:
Import-Module -Name Microsoft.Graph
I have PSVersion 5.1.17763.5458 installed on my Windows 2019 server.
I have the folowwing error:
PS C:\Users\username> Import-Module -Name Microsoft.Graph
Import-Module : Function Get-MgEntitlementManagementResourceRoleScopeRoleResourceScope cannot be created because
function capacity 4096 has been exceeded for this scope.
At line:1 char:1
- Import-Module -Name Microsoft.Graph
-
+ CategoryInfo : InvalidOperation: (Get-MgEntitleme...leResourceScope:String) [Import-Module], SessionSta teOverflowException + FullyQualifiedErrorId : FunctionOverflow,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\Users\username>
Do you have a solution?
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.
4 answers
Sort by: Most helpful
-
Anonymous
2024-02-28T15:10:48+00:00 -
Anonymous
2024-02-29T06:11:52+00:00 Hi JUHEL Freddy,
You can manually change values of the variables $MaximumFunctionCount and $MaximumVariableCount
$MaximumVariableCount = 10000 $MaximumFunctionCount = 10000
-
Anonymous
2024-03-01T09:18:28+00:00 thanks
it works fine
-
Anonymous
2025-01-16T15:22:46+00:00 I also have the same issue. I set the $MaximumVariableCount = 10000 and the $MaximumFunctionCount = 10000 but still get the same error. I am on version 5.1.22621.4249 installed on Windows 11.
Import-Module : Function Get-MgTenantRelationshipDelegatedAdminCustomer cannot be created because function capacity 4096 has been exceeded for this scope.
At C:\Users\username\Test.ps1:28 char:1
- Import-Module -Name Microsoft.Graph -Cmdlet Microsoft.Graph.Users.Get ...
-
+ CategoryInfo : InvalidOperation: (Get-MgTenantRel...edAdminCustomer:String) [Import-Module], SessionStateOverflowException + FullyQualifiedErrorId : FunctionOverflow,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Function Get-MgUser cannot be created because function capacity 4096 has been exceeded for this scope.
At C:\Users\username\Test.ps1:28 char:1
- Import-Module -Name Microsoft.Graph.Users
-
+ CategoryInfo : InvalidOperation: (Get-MgUser:String) [Import-Module], SessionStateOverflowException + FullyQualifiedErrorId : FunctionOverflow,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Function Get-MgUserInferenceClassification cannot be created because function capacity 4096 has been exceeded for this scope.
At C:\Users\username\Test.ps1:28 char:1
- Import-Module -Name Microsoft.Graph.Mail
-
+ CategoryInfo : InvalidOperation: (Get-MgUserInferenceClassification:String) [Import-Module], SessionStateOverflowException + FullyQualifiedErrorId : FunctionOverflow,Microsoft.PowerShell.Commands.ImportModuleCommand