大网数据广告活动
域与目录服务

IDX14102 Error When Using Microsoft Graph PowerShell

· 52CE 我爱测

Resolves an error that occurs when you run the Microsoft Graph PowerShell cmdlet Connect-MgGraph.

This article provides solutions to the error "IDX14102: Unable to decode the header" that occurs when you use Microsoft Graph PowerShell.

Symptoms

When running the Microsoft Graph PowerShell command Connect-MgGraph -AccessToken $token, you receive the following error:

IDX14102: Unable to decode the header

Cause

This error occurs because an invalid access token is passed to the AccessToken parameter of the Connect-MgGraph cmdlet. This problem often occurs when the token is obtained via Azure PowerShell's Get-AzAccessToken cmdlet and passed as a SecureString. This behavior is observed starting with version 5.0.0 of the Az.Accounts module. Starting from Microsoft Graph PowerShell version 2.28.0, the Connect-MgGraph command accepts only a plain string as the AccessToken parameter.

Solution

Here are two solutions for resolving this issue:

  • Make sure the access token passed to the AccessToken parameter of the Connect-MgGraph cmdlet is valid.

    For more information about access tokens, see Access tokens in the Microsoft identity platform.

  • If you use the Get-AzAccessToken cmdlet to obtain the access token, use one of the following methods:

    • Downgrade Az.Accounts to version 4.2.0 to avoid the token being returned as a SecureString.

    • Convert the token from SecureString to String:

      $microsoftGraphToken = Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com"
      
      Connect-MgGraph -AccessToken (ConvertFrom-SecureString -SecureString $microsoftGraphToken.Token -AsPlainText)
      

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 07/01/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。