【问题标题】:MS Graph Powershell SDK - Cannot process argument transformation on parameter 'BodyParameter'MS Graph Powershell SDK - 无法处理参数“BodyParameter”的参数转换
【发布时间】:2022-01-12 23:32:11
【问题描述】:

我目前正在尝试创建一个可以通过 MS Graph Powershell SDK 部署的安全基线。但是,我在输入请求正文时遇到了问题。

请求位于脚本的单独 JSON 文件中,如下所示:

{
   "description": "Basic Security Configuration recommended by company.",
   "displayName": "Company Security Baseline",
   "value": [
       {
           "definitionId": "deviceConfiguration--windows10EndpointProtectionConfiguration_defenderOfficeMacroCodeAllowWin32ImportsType",
           "valueJson": "\"warn\"",
           "@odata.type": "#microsoft.graph.deviceManagementStringSettingInstance",
           "value": "warn"
       }
   ]
}

然后我按如下方式从该文件中获取内容并将其输入到 New-MgDeviceManagementTemplateInstance 命令中。

# Create request from JSON file.
$request = Get-Content SecurityBaseline.json 

# Create new template instance.
$instance = New-MgDeviceManagementTemplateInstance -DeviceManagementTemplateId $templateId -BodyParameter $request

之后我收到此错误:

New-MgDeviceManagementTemplateInstance : Cannot process argument transformation on parameter 'BodyParameter'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type
"Microsoft.Graph.PowerShell.Models.IPaths1Acen0GDevicemanagementTemplatesDevicemanagementtemplateIdMicrosoftGraphCreateinstancePostRequestbodyContentApplicationJsonSchema".
At line:1 char:112
+ ...  -DeviceManagementTemplateId "$($templateId)" -BodyParameter $request
+                                                                  ~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [New-MgDeviceManagementTemplateInstance], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MgDeviceManagementTemplateInstance

任何有关我需要输入此数据的格式的帮助,将不胜感激。

【问题讨论】:

  • 这似乎是 beta SDK 本身的问题。由于这是 beta cmdlet,它可能仍在更改中,您可以尝试使用 PowerShell 运行原始 http 请求并查看是否获得 200。
  • 你可以在 GitHub 上打开一个问题:msgraph-sdk-powershell

标签: json powershell microsoft-graph-api microsoft-graph-sdks


【解决方案1】:

不确定这是否是测试版 SDK 的问题,或者它是否按预期工作,但这似乎暂时有效。

$instance = New-MgDeviceManagementTemplateInstance -DeviceManagementTemplateId $templateId -BodyParameter "$request"

【讨论】:

    猜你喜欢
    • 2015-01-21
    • 2014-02-26
    • 2021-11-22
    • 2014-05-31
    • 2023-03-29
    • 1970-01-01
    • 2021-12-16
    • 2017-08-22
    • 2021-05-22
    相关资源
    最近更新 更多