You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用New-AzManagementGroup创建Azure管理组报错求助

Azure New-AzManagementGroup 类型转换报错解决方案

你遇到的Unable to cast object of type 'Microsoft.Azure.Management.ManagementGroups.Models.ManagementGroup' to type 'Newtonsoft.Json.Linq.JObject'报错是Az.Resources旧版本的已知序列化缺陷,出现在调用New-AzManagementGroup时传递父管理组对象/属性的场景,可通过以下方案解决:

  • 方案1:升级Az.Resources模块到最新稳定版
    1. 以管理员权限启动PowerShell,执行升级命令:
    Update-Module -Name Az.Resources -Force -AllowClobber
    
    1. 重启PowerShell会话,重新登录Azure账号:
    Connect-AzAccount
    
    1. 重新执行原创建命令即可正常运行。
  • 方案2:强制转换父ID为纯字符串
    如果暂时无法升级模块,可将父ID强制转为字符串类型传递,避开类型识别异常:
    New-AzManagementGroup -GroupId "MI-Test-testing00" -ParentId "$($parent.Id)"
    
  • 方案3:使用Azure CLI作为替代
    也可以直接用跨平台的Azure CLI完成管理组创建,不存在PowerShell模块的类型兼容问题:
    az account management-group create --name MI-Test-testing00 --parent MI-Test
    

内容的提问来源于stack exchange,提问作者Divyansh Saxena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 17:24:03