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

未關閉
#3,628 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
powershell

研究方向

首先,在 Windows PowerShell 5.1 下使用模組版本 2.25.0 和 2.37.0 透過 Connect-MgGraph 重現該行為,然後將其與 PowerShell 7 進行比較。當約兩分鐘的逾時受到遵守且 WAM 帳戶選取對話方塊自動關閉時,修正即告完成;該 issue 中未識別來源檔案或測試。

由索引模型根據 Issue 內容生成。

描述

type:bug
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_
主要語言
C#
星號
909
分支
234
平均合併
3 天 20 小時
30 天內合併 PR
19

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoftgraph/msgraph-sdk-powershell 的其他 Issue

查看 microsoftgraph/msgraph-sdk-powershell 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。