-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9106 from Azure/o365actionsadd
addition of two new actions in o365
- Loading branch information
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...5/Playbooks/CustomConnector/O365_Defender_FunctionAppConnector/GetInboxRule/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "function", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
...ice 365/Playbooks/CustomConnector/O365_Defender_FunctionAppConnector/GetInboxRule/run.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
$flag = 0 | ||
# Write to the Azure Functions log stream. | ||
Write-Host "Fetching list of Malware policies" | ||
|
||
$Mailbox = $Request.Body.Mailbox | ||
# Interact with query parameters or the body of the request. | ||
|
||
try{ | ||
if($Mailbox) | ||
{ | ||
$Result = Get-InboxRule -Mailbox "$Mailbox" | ||
if($?){Write-Host "Successfully fetched list of Inbox Rules" | ||
$flag = 1 | ||
} | ||
else | ||
{Write-Host "Failed to fetch list of Inbox Rules"} | ||
|
||
}else | ||
{Write-Host "Mailbox not provided : Failed to fetch list of Inbox Rules"} | ||
} | ||
|
||
catch{ | ||
Write-Host "$_.Exception" | ||
$Result = "$_.Exception" | ||
} | ||
|
||
finally{ | ||
if($flag){ | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $Result | ||
})}else{ | ||
|
||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::NotFound | ||
Body = $Result | ||
}) | ||
} | ||
} |
Binary file modified
BIN
+1.84 KB
(120%)
.../Playbooks/CustomConnector/O365_Defender_FunctionAppConnector/O365DefenderFunctionApp.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
...laybooks/CustomConnector/O365_Defender_FunctionAppConnector/RemoveInboxRule/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "function", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
} | ||
] | ||
} |
45 changes: 45 additions & 0 deletions
45
... 365/Playbooks/CustomConnector/O365_Defender_FunctionAppConnector/RemoveInboxRule/run.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
$flag = 0 | ||
# Write to the Azure Functions log stream. | ||
Write-Host "Proceeding with delete of Inbox Rule" | ||
|
||
$Mailbox = $Request.Body.Mailbox | ||
$Identity = $Request.Body.Identity | ||
# Interact with query parameters or the body of the request. | ||
|
||
try{ | ||
if($Mailbox -AND $Identity) | ||
{ | ||
$Result = Remove-InboxRule -Mailbox "$Mailbox" -Identity "$Identity" -Confirm:$false | ||
if($?){Write-Host "Successfully Deleted the rule" | ||
$flag = 1 | ||
} | ||
else | ||
{Write-Host "Failed to delete Inbox Rules"} | ||
|
||
}else | ||
{Write-Host "Mailbox or Identity not provided : Failed to delete Inbox Rules"} | ||
} | ||
|
||
catch{ | ||
Write-Host "$_.Exception" | ||
$Result = "$_.Exception" | ||
} | ||
|
||
finally{ | ||
if($flag){ | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $Result | ||
})}else{ | ||
|
||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::NotFound | ||
Body = $Result | ||
}) | ||
} | ||
} |