Recently while trying to import the Microsoft Graph PowerShell Module, I encountered an error. The error states the “function capacity 4096 has been exceeded for this scope.

I have also seen this before, but not for functions but variables. To understand the error, you first need to realize there is a set of memory allocations for loading functions, variables, aliases, errors, history, and drives. Each of these options has a corresponding variable for its maximum value.


These variables are “Preference Variables,” used to store default values within the console or terminal. There are in fact quite a few of these.

Executing each variable returns the current setting. For example, when you run “$MaximumFunctionCount,” it returns “4096“, the number displayed within the error message. 

You can modify the variable values, allowing more memory allocation to help store more history or increase the number of variables for reuse.

# Increase the Function Count
$MaximumFunctionCount = 8192

# Increase the Variable Count
$MaximumVariableCount = 8192

Now the import works as the limit allows for loading of all the functions into the current scope.