'Disable alert rule with empty TargetResourceRegion

I am trying to disable an alert rule via powershell, but I am getting the following error:

Get-AzMetricAlertRuleV2 -ResourceGroupName "myresourcegroupname"  -Name "alertname" | Add-AzMetricAlertRuleV2 -DisableRule

Add-AzMetricAlertRuleV2: Cannot validate argument on parameter 'TargetResourceRegion'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

I have tried it without the | Add-AzMetricAlertRuleV2 -DisableRule:

Get-AzMetricAlertRuleV2 -ResourceGroupName "myresourcegroupname"  -Name "alertname"
Output:
Criteria             : {Metric1}
Actions              : {/subscriptions/subscriptionguid/resourceGroups/myresourcegroupname/providers/microsoft.insights/actionGroups/actiongroupname}
ResourceGroup        : myresourcegroupname
Description          :
Severity             : 3
Enabled              : True
Scopes               : {/subscriptions/subscriptionguid/resourceGroups/myresourcegroupname/providers/Microsoft.Sql/servers/myservername/elasticpools/myelasticpoolname}
EvaluationFrequency  : 00:01:00
WindowSize           : 00:01:00
TargetResourceType   : Microsoft.Sql/servers/elasticpools
TargetResourceRegion :
AutoMitigate         : True
LastUpdatedTime      :
IsMigrated           :
Id                   : /subscriptions/3subscriptionguid/resourceGroups/myresourcegroupname/providers/microsoft.insights/metricAlerts/alertname
Name                 : alertname
Type                 : Microsoft.Insights/metricAlerts
Location             : global
Tags                 : {}
Kind                 :
Etag                 :

My previous command was telling me that 'TargetResourceRegion' is null or empty. And that's right corresponding to the output above. But how can I disable that alert rule from powershell, with an empty TargetResourceRegion?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source