Skip to content

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

@i5513

Description

@i5513

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

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_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions