【发布时间】: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