1
+ # ----------------------------------------------------------------------------------
2
+ #
3
+ # Copyright Microsoft Corporation
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ----------------------------------------------------------------------------------
14
+
15
+ <#
16
+ . SYNOPSIS
17
+ List Actions by Alert Rule
18
+ #>
19
+ function Get-AzSentineAlertRulelAction-ListByAlertRule
20
+ {
21
+
22
+ $LogicAppResourceId = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
23
+ $LogicAppResourceId2 = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Get-MDATPInvestigationPackage"
24
+
25
+ # Create Alert Rule
26
+ $alertRule = New-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - Type Scheduled - Enabled $true - DisplayName " PoshModuleTest" - SuprressionDuration " PT5H" - SuprressionEnabled $false
27
+ # Create Alert Rule Action
28
+ $action = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId
29
+ # Create Alert Rule Action
30
+ $action2 = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId2
31
+
32
+ # Get Alert Rule Actions
33
+ $actions = Get-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
34
+ # Validate
35
+ Validate- Actions $actions
36
+
37
+ # Cleanup
38
+ Remove-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
39
+ }
40
+
41
+ <#
42
+ . SYNOPSIS
43
+ Get Action
44
+ #>
45
+ function Get-AzSentinelAlertRuleAction-GetAction
46
+ {
47
+
48
+ $LogicAppResourceId = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
49
+
50
+ # Create Alert Rule
51
+ $alertRule = New-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - Type Scheduled - Enabled $true - DisplayName " PoshModuleTest" - SuprressionDuration " PT5H" - SuprressionEnabled $false
52
+ # Create Alert Rule Action
53
+ $action = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId
54
+
55
+ # Get Alert Rule Action
56
+ $action = Get-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name ) - ActionId ($action.Name )
57
+ # Validate
58
+ Validate- Action $action
59
+
60
+ # Cleanup
61
+ Remove-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
62
+ }
63
+
64
+ <#
65
+ . SYNOPSIS
66
+ Create Action
67
+ #>
68
+ function New-AzSentinelAlertRuleAction-Create
69
+ {
70
+ $LogicAppResourceId = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
71
+
72
+ # Create Alert Rule
73
+ $alertRule = New-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - Type Scheduled - Enabled $true - DisplayName " PoshModuleTest" - SuprressionDuration " PT5H" - SuprressionEnabled $false
74
+ # Create Alert Rule Action
75
+ $action = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId
76
+
77
+ # Validate
78
+ Validate- Action $action
79
+
80
+ # Cleanup
81
+ Remove-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
82
+ }
83
+
84
+ <#
85
+ . SYNOPSIS
86
+ Update Action
87
+ #>
88
+ function Set-AzSentinelAlertRuleAction-Update
89
+ {
90
+ $LogicAppResourceId = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
91
+ $LogicAppResourceId2 = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Get-MDATPInvestigationPackage"
92
+
93
+ # Create Alert Rule
94
+ $alertRule = New-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - Type Scheduled - Enabled $true - DisplayName " PoshModuleTest" - SuprressionDuration " PT5H" - SuprressionEnabled $false
95
+ # Create Alert Rule Action
96
+ $action = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId
97
+
98
+ # update action
99
+ $action = Set= AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId2
100
+
101
+ # Validate
102
+ Validate- Action $action
103
+
104
+ # Cleanup
105
+ Remove-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
106
+ }
107
+
108
+ <#
109
+ . SYNOPSIS
110
+ Delete Action
111
+ #>
112
+ function Remove-AzSentinelAlertRuleAction-Delete
113
+ {
114
+ $LogicAppResourceId = " /subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
115
+
116
+ # Create Alert Rule
117
+ $alertRule = New-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - Type Scheduled - Enabled $true - DisplayName " PoshModuleTest" - SuprressionDuration " PT5H" - SuprressionEnabled $false
118
+ # Create Alert Rule Action
119
+ $action = New-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - LogicAppResourceId $LogicAppResourceId
120
+ Remove-AzSentinelAlertRuleAction - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - ActionId ($action.Name )
121
+ # Validate
122
+ Validate- Action $action
123
+
124
+ # Cleanup
125
+ Remove-AzSentinelAlertRule - ResourceGroupName (Get-TestResourceGroupName ) - WorkspaceName (Get-TestWorkspaceName ) - AlertRuleId ($alertRule.Name )
126
+ }
127
+
128
+ <#
129
+ . SYNOPSIS
130
+ Validates a list of actions
131
+ #>
132
+ function Validate-Actions
133
+ {
134
+ param ($actions )
135
+
136
+ Assert-True { $actions.Count -gt 0 }
137
+
138
+ Foreach ($action in $actions )
139
+ {
140
+ Validate- Action $action
141
+ }
142
+ }
143
+
144
+ <#
145
+ . SYNOPSIS
146
+ Validates a single action
147
+ #>
148
+ function Validate-Action
149
+ {
150
+ param ($action )
151
+
152
+ Assert-NotNull $action
153
+ }
0 commit comments