Hey everyone! I'm trying to update the detection method for a Win32 app using the Microsoft Graph API. I understand that the stable version doesn't support this feature, but the beta version does. As an Intune admin, I can manually update the detection method, and I've written a PowerShell script to automate this process. However, I'm running into a "400 Bad Request" error when I try to send an update request. Here's a quick overview of my script and the error I'm getting. Any insights or suggestions on how to resolve this issue would be greatly appreciated!
2 Answers
It looks like the Invoke-MgGraph cmdlet operates independently and may not use the session created by Connect-MgGraph. I suggest testing by directly including an authentication token in your request. Have you looked into how to do that?
Additionally, make sure to include the rule type in your payload. Here’s a tweaked example of how you could structure your script detection:
```powershell
$scriptDetection = @{
"@odata.type" = "#microsoft.graph.win32LobAppPowerShellScriptRule"
ruleType = "detection"
detectionType = "script"
scriptContent = $encodedScript
runAs32Bit = $true
enforceSignatureCheck = $false
}
```
This might resolve the validation failure you're encountering!
Thanks for the suggestion! I tried incorporating the rule type, but I'm still getting a similar "400 Bad Request" error. It’s frustrating!

I've encountered similar issues in the past. If you have details on how to retrieve the auth token, sharing that would be super helpful!