【发布时间】:2021-07-19 05:51:14
【问题描述】:
我在更新 Intune 设备脚本时遇到问题。我的代码在本地机器上运行 VS 代码时有效,但在通过 Azure DevOps Pipeline 运行时出错。
$updateURI: https://graph.microsoft.com/beta/deviceManagement/deviceManagementScripts/c24***********6a
$postbody:
{
$Resource = "deviceManagementScripts"
$ODataType = "#microsoft.graph.deviceManagementScript"
$postbody = @{
"@odata.type" = $ODataType;
"displayName" = $Displayname;
"description" = $Description;
"scriptContent" = $UploadScriptEncoded;
"runAsAccount" = "user";
"enforceSignatureCheck" = "false";
"fileName" = $Filename } | ConvertTo-Json
}
休息方法:
Invoke-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch -Body $postbody -ContentType "application/JSON"
错误:
Invoke-RestMethod: /Users/runner/work/1/s/inline.ps1:111 线 | 111 |调用-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch ... | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ | {"error":{"code":"BadRequest","message":"{\r\n "_version": | 3,\r\n "Message": "发生错误 - 操作 ID | (用于客户支持):00000000-0000-0000-0000-000000000000 - |活动 ID:c27be3e1-4de1-43c2-8f5d-9db86608b2a7 - 网址: | https://fef.amsua0202.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/deviceManagement/deviceManagementScripts%28%274ce72c8b-1086-404d-8c9f-db9ff8b95d35%27%29?api-version=5021-03-18\",\r\n "CustomApiErrorPhrase": "",\r\n "RetryAfter": null,\r\n "ErrorSourceService": "",\r\n "HttpHeaders": "{}"\r\n}", "innerError":{"date":"2021-04-23T21:42:36","request-id":"c27be3e1-4de1-43c2-8f5d-9db86608b2a7","client-request-id":"c27be3e1- 4de1-43c2-8f5d-9db86608b2a7"}}}
##[错误]PowerShell 退出,代码为“1”。
XML:
<ODataError xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Microsoft.OData.Core">
<Details i:nil="true"/>
<ErrorCode>UnsupportedApiVersion</ErrorCode>
<InnerError i:nil="true"/>
<InstanceAnnotations/>
<Message>{ "_version": 3, "Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: d7777c39-60cd-46e3-bca0-a24148d2ccb6 - Url: https://fef.amsua0202.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/deviceManagement/deviceManagementScripts%28%274ce72c8b-1086-404d-8c9f-db9ff8b95d35%27%29?api-version=5021-03-18%5C%22,%5Cr%5Cn", "CustomApiErrorPhrase": "", "RetryAfter": null, "ErrorSourceService": "", "HttpHeaders": "{}" }</Message>
<Target i:nil="true"/>
</ODataError>
请在此处帮助了解我缺少什么。 提前致谢。
【问题讨论】:
标签: azure powershell azure-devops