Forum Discussion
Use powershell to add a tag to a MS Defender device
- dmarquesgnAug 21, 2024Iron Contributor
jbmartin6 Thanks for the tips.
Finally it's working. First, instead of using a variable on the creation of the body, like this:
$Body = @{"Value"=$Tag;"Action"="Add"}
I removed the variable and added a value and it worked. Then I start messing with the variable values and then, the same variable value I had before worked, without really understanding why, but now it's working fine.
- jbmartin6Aug 22, 2024Iron Contributor
Great that it is working! I had a similar experience trying to run hunting queries using the API, there were some character escapes needed but then sometimes it still failed. I'm sure there is some technical wrinkle of strings or powershell that we are missing.
- dmarquesgnAug 22, 2024Iron Contributor
Well, this is really odd. I had it working, but of course it was in an area of the script for testing. Then moved the code to the correct area of the script and today went to test the full script and it's not working again, prompting the same error of the "InvalidRequestBody".
So now I'm not really sure what is the problem, but it's not working anymore and don't have a clue why.