I have a script to export list of all alert rule created in OMS (Log Analytics). It is running fine and i can see result in my temp folder with name OMSAlert.csv. But when i am running same script in my another Azure subscription for a workspace i am getting error. Its bit strange and i am not ware why its is happening.
You can find the code block https://social.technet.microsoft.com/Forums/en-US/4d01d3b7-1924-4e6b-9b72-a7bfe4732d19/error-running-script-for-another-oms-workspace?forum=winserverpowershell here.
The error which i am getting is as below:-
convertfrom-json : Invalid JSON primitive: .
At C:\Users\kumar_g\Downloads\retrievealerts-oms.ps1:130 char:80
- … et “$($_.value.id)/actions?api-version=2015-03-20” | convertfrom-json
- CategoryInfo : NotSpecified: ( [ConvertFrom-Json], ArgumentException
- FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
Note:- Same script without any changes running fine for another subscription. I have also replaced api version from 2015-03-20 to 2016-04-01 but still no luck.