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

New-MgSiteList执行报错:无法确定列定义类型求解决方案

解决New-MgSiteList创建带列列表时的类型识别错误

问题根源

报错“Unable to determine type of provided column definition”的核心原因是列定义缺少显式的类型声明或对应类型的必填属性。Microsoft Graph要求创建列时必须明确指定ColumnType,并提供该类型对应的配置对象(如文本列的Text、数字列的Number),仅填写名称和描述会导致系统无法识别列类型。

解决步骤

1. 严格遵循列定义的完整结构

每个列必须包含以下核心字段:

  • Name:列的内部标识(英文,无特殊字符)
  • DisplayName:列的显示名称(支持中文)
  • ColumnType:列的类型(如Text、Number、DateTime等)
  • 对应类型的配置对象:比如Text、Number、DateTime,每个类型有自己的必填参数

2. 完整示例代码(创建EXO邮箱大小报告列表)

# 替换为你的站点ID
$siteId = "contoso.sharepoint.com,xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# 构造列表及列定义
$listDefinition = @{
    DisplayName = "EXO邮箱大小报告"
    Description = "存储Exchange Online邮箱的大小统计数据"
    # 指定列表模板为通用列表
    List = @{
        Template = "genericList"
    }
    # 定义所需列
    Columns = @(
        # 邮箱地址(文本列)
        @{
            Name = "MailboxAddress"
            DisplayName = "邮箱地址"
            ColumnType = "Text"
            Text = @{
                AllowMultipleLines = $false
                MaxLength = 255
            }
        },
        # 总大小(数字列,保留2位小数)
        @{
            Name = "TotalSizeMB"
            DisplayName = "总大小(MB)"
            ColumnType = "Number"
            Number = @{
                DecimalPlaces = 2
                Maximum = 999999
                Minimum = 0
                ShowAsPercentage = $false
            }
        },
        # 最后同步时间(日期时间列)
        @{
            Name = "LastSyncTime"
            DisplayName = "最后同步时间"
            ColumnType = "DateTime"
            DateTime = @{
                DisplayAs = "DateTime"
                Format = "DateTime"
            }
        }
    )
}

# 执行创建命令
New-MgSiteList -SiteId $siteId -BodyParameter $listDefinition

3. 额外注意事项

  • 确保Microsoft Graph PowerShell模块为最新版本:执行Update-Module Microsoft.Graph更新,旧版本可能存在API兼容性问题。
  • 若仍报错,添加-Debug参数查看请求详情:New-MgSiteList -SiteId $siteId -BodyParameter $listDefinition -Debug,对比Graph API文档检查列定义是否符合要求。
  • 列的Name字段必须唯一,且不能包含空格、特殊字符,只能使用字母、数字和下划线。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 09:48:21