microsoftgraph / microsoftgraph/msgraph-sdk-powershell

In powershell 5.1: Connect-MgGraph timeout behavior regression in versions >= 2.35 (does not respect 2-minute timeout)

Open
#3,628 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

We've observed a change in timeout behavior for Connect-MgGraph across different versions of the Microsoft.Graph PowerShell module. In our teams this behaviour is

In version 2.25:

  • The expected timeout of approximately 2 minutes is respected.
  • The account selection window (interactive login) closes correctly when the timeout is reached.
Image

In versions 2.35 and later:

  • The operation no longer respects the ~2 minute timeout.
  • Instead, it fails after approximately 5 minutes.
  • Additionally, the WAM account selection dialog does NOT close automatically when the timeout occurs.
  • The dialog remains open indefinitely until manually closed by the user.
Image

Actual behavior:

  • Timeout occurs after ~5 minutes.
  • WAM dialog remains open and must be closed manually.

This appears to be a regression compared to version 2.25, even though previously it was indicated that timeout behavior had not changed.

The WAM dialog not closing is a known issue?

If needed, we can provide additional environment details.

Additional context:

  • This behavior has been reproduced across multiple machines.
  • Several team members are experiencing the same issue, so it does not appear to be limited to a single environment or device.

Thanks

Expected behavior
  • Timeout occurs after ~2 minutes.
  • WAM dialog closes automatically.
How to reproduce

Run with 2.25 first and then with 2.37.0

$ini = Date
Write-Output "${ini}: Inicio"
powershell.exe -command {
    $tenantId =  "xxxx"
    Connect-MgGraph -ErrorAction stop -ContextScope Process -TenantId $tenantId

}
$fin = Date
Write-Warning ("Tardó: {0}" -f ($fin - $ini).totalminutes)
SDK Version

2.37.0

Latest version known to work for scenario above?

2.25.0

Known Workarounds

The workaround I found now is not working, sometimes connect-mggraph hangs

UPDATE: As 2026-07-02 with 110 seconds of timeout the workaround is working

With powershell 7 the behaviour is the correct (change powershell.exe to pwsh.exe)

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


### Configuration

Name                           Value
----                           -----
PSVersion                      5.1.22621.6931
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.6931
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

### 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 behavior with Connect-MgGraph under Windows PowerShell 5.1 using module versions 2.25.0 and 2.37.0, then compare it with PowerShell 7. The fix is complete when the approximately two-minute timeout is respected and the WAM account-selection dialog closes automatically; no source files or tests are identified in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.