microsoftgraph / microsoftgraph/msgraph-sdk-powershell

import-module with $MaximumFunctionCount = 32768 fails in PowerShell 5.1

Open
#3,413 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs Investigation type:bug
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Describe the bug

import-module microsoft.graph with $MaximumFunctionCount = 32768 fails in PowerShell 5.1 when the variable is set in the script, but works fine if it is done on the command line.

##
## Setting in script
##

if ( 32768 -gt $MaximumVariableCount ) {

    $MaximumVariableCount = 32768;

};

if ( 32768 -gt $MaximumFunctionCount ) {

    $MaximumFunctionCount = 32768;

};

"MaximumVariableCount $MaximumVariableCount ";
"MaximumFunctionCount $MaximumFunctionCount";

Image

Script display unfortunately with error messages in Norwegian. But you get the drift.

Image

BTW. I know this works fine in PowerShell 7.x, but those who run this might not have that installed.

Expected behavior

That import-module works the same whether it is a script or on command line in PowerShell 5.1.

How to reproduce

Run script or copy commands from script to command line.

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the difference between running the provided assignments in a PowerShell 5.1 script and at the command line, then import microsoft.graph in both cases and compare the errors. The issue is resolved when module import behaves consistently in both contexts, or the PowerShell 5.1 limitation and workaround are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.