Reputation: 3
I am running in issue with updating Intune Device Scripts. My code works when I run through VS code on local machine but errors out when running through 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
}
RestMetthod:
Invoke-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch -Body $postbody -ContentType "application/JSON"
ERROR:
Invoke-RestMethod: /Users/runner/work/1/s/inline.ps1:111 Line | 111 | Invoke-RestMethod -Uri $updateURI -Headers $authHeader -Method Patch … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | {"error":{"code":"BadRequest","message":"{\r\n "_version": | 3,\r\n "Message": "An error has occurred - Operation ID | (for customer support): 00000000-0000-0000-0000-000000000000 - | Activity ID: c27be3e1-4de1-43c2-8f5d-9db86608b2a7 - Url: | 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"}}}
##[error]PowerShell exited with code '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>
Please help here in understanding what am I missing. Thanks in advance.
Upvotes: 0
Views: 709
Reputation: 5242
Please try deleting the @odata.type
parameter in the $postbody
and running it again.
Upvotes: 0