-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathGet-CIPPAlertQuarantineReleaseRequests.ps1
More file actions
67 lines (61 loc) · 2.75 KB
/
Get-CIPPAlertQuarantineReleaseRequests.ps1
File metadata and controls
67 lines (61 loc) · 2.75 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function Get-CIPPAlertQuarantineReleaseRequests {
<#
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[Alias('input')]
$InputValue,
$TenantFilter
)
#Add rerun protection: This Monitor can only run once every hour.
$Rerun = Test-CIPPRerun -TenantFilter $TenantFilter -Type 'ExchangeMonitor' -API 'Get-CIPPAlertQuarantineReleaseRequests'
if ($Rerun) {
return
}
$HasLicense = Test-CIPPStandardLicense -StandardName 'QuarantineReleaseRequests' -TenantFilter $TenantFilter -RequiredCapabilities @(
'EXCHANGE_S_STANDARD',
'EXCHANGE_S_ENTERPRISE',
'EXCHANGE_S_STANDARD_GOV',
'EXCHANGE_S_ENTERPRISE_GOV',
'EXCHANGE_LITE'
)
if (-not $HasLicense) {
return
}
try {
$cmdParams = @{
PageSize = 1000
ReleaseStatus = 'Requested'
StartReceivedDate = (Get-Date).AddHours(-6)
EndReceivedDate = (Get-Date).AddHours(0)
}
$RequestedReleases = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-QuarantineMessage' -cmdParams $cmdParams -ErrorAction Stop | Select-Object -ExcludeProperty *data.type* | Sort-Object -Property ReceivedTime
if ($RequestedReleases) {
# Get the CIPP URL for the Quarantine link
$CippConfigTable = Get-CippTable -tablename Config
$CippConfig = Get-CIPPAzDataTableEntity @CippConfigTable -Filter "PartitionKey eq 'InstanceProperties' and RowKey eq 'CIPPURL'"
$CIPPUrl = 'https://{0}' -f $CippConfig.Value
$AlertData = foreach ($Message in $RequestedReleases) {
[PSCustomObject]@{
Identity = $Message.Identity
MessageId = $Message.MessageId
Subject = $Message.Subject
SenderAddress = $Message.SenderAddress
RecipientAddress = $Message.RecipientAddress -join '; '
Type = $Message.Type
PolicyName = $Message.PolicyName
ReleaseStatus = $Message.ReleaseStatus
ReceivedTime = $Message.ReceivedTime
QuarantineViewUrl = "$CIPPUrl/email/administration/quarantine?tenantFilter=$TenantFilter"
Tenant = $TenantFilter
}
}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
}
} catch {
Write-LogMessage -API 'Alerts' -tenant $TenantFilter -message "QuarantineReleaseRequests: $(Get-NormalizedError -message $_.Exception.Message)" -sev Error
}
}