-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-LogSearchAlert.ps1
More file actions
38 lines (29 loc) · 1.17 KB
/
Copy pathRemove-LogSearchAlert.ps1
File metadata and controls
38 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Function Remove-LogSearchAlert{
<#
.SYNOPSIS
Removes a Log Searh Alert
.DESCRIPTION
Removes a Log Search Alert
.PARAMETER subscriptionId
The ID of the Azure Subscription
.PARAMETER resourceGroupName
The name of the resource group in which the alert resides
.EXAMPLE
C:\PS> Remove-LogSearchAlert -opResourceGroupName "MyOperationalInsightsResourceGroup" -ruleName "MyRule"
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$True, HelpMessage='The resource group for the Operational Insights Workspace')]
[string]$opResourceGroupName,
[Parameter(Mandatory=$True, HelpMessage='Name of the alert rule')]
[string]$ruleName
)
#check if alert rule exists
$rule = Get-AzScheduledQueryRule -ResourceGroupName $opResourceGroupName -Name $ruleName -ErrorAction SilentlyContinue
if ($rule) {
Write-Output "Deleting alert rule: $ruleName"
Remove-AzScheduledQueryRule -ResourceGroupName $opResourceGroupName -Name $ruleName
} else {
Write-Output "Alert rule: $ruleName could not be found"
}
}