【发布时间】:2019-12-04 17:15:21
【问题描述】:
$condition1 = New-AzureRmActivityLogAlertCondition -Field 'category' -Equal 'Administrative'
$condition2 = New-AzurermActivityLogAlertCondition -Field 'resourceType' -Equal 'Microsoft.Network/NetworkSecurityGroups'
$email1 = New-AzureRmActionGroupReceiver -Name 'alertget' -EmailReceiver -EmailAddress '<emailaddress>'
$actionGrp=Set-AzureRmActionGroup -Name "withpowershell" -ResourceGroup "<rgname>" -ShortName "Palert" -Receiver $email1
Set-AzurermActivityLogAlert -Location 'Global' -Name 'alertme' -ResourceGroupName '<rgname>' -Scope '/subscriptions/<subsID>' -Action $actionGrp -Condition $condition1,$condition2
但是每次我运行这段代码时,我都会收到如下所述的错误:
Set-AzureRmActivityLogAlert : Cannot bind parameter 'Action'. Cannot convert the
"Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupResource" value of type
"Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupResource" to type
"Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup".
At line:1 char:163
+ ... ions/911df94d-12e9-4695-a90f-943a1bef518d' -Action $actionGrp -Condit ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-AzureRmActivityLogAlert], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Insights.ActivityLogAlert.SetAzureRmActivityLogAlertCommand
请告诉我解决办法
【问题讨论】:
标签: azure powershell