|
| 1 | +function Get-CIPPAlertQuarantineReleaseRequests { |
| 2 | + <# |
| 3 | + .FUNCTIONALITY |
| 4 | + Entrypoint |
| 5 | + #> |
| 6 | + [CmdletBinding()] |
| 7 | + param ( |
| 8 | + [Parameter(Mandatory = $false)] |
| 9 | + [Alias('input')] |
| 10 | + $InputValue, |
| 11 | + $TenantFilter |
| 12 | + ) |
| 13 | + |
| 14 | + $HasLicense = Test-CIPPStandardLicense -StandardName 'QuarantineReleaseRequests' -TenantFilter $TenantFilter -RequiredCapabilities @( |
| 15 | + 'EXCHANGE_S_STANDARD', |
| 16 | + 'EXCHANGE_S_ENTERPRISE', |
| 17 | + 'EXCHANGE_S_STANDARD_GOV', |
| 18 | + 'EXCHANGE_S_ENTERPRISE_GOV', |
| 19 | + 'EXCHANGE_LITE' |
| 20 | + ) |
| 21 | + |
| 22 | + if (-not $HasLicense) { |
| 23 | + return |
| 24 | + } |
| 25 | + |
| 26 | + try { |
| 27 | + $RequestedReleases = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-QuarantineMessage' -cmdParams @{ PageSize = 1000; ReleaseStatus = 'Requested' } -ErrorAction Stop | Select-Object -ExcludeProperty *data.type* |
| 28 | + |
| 29 | + if ($RequestedReleases) { |
| 30 | + # Get the CIPP URL for the Quarantine link |
| 31 | + $CippConfigTable = Get-CippTable -tablename Config |
| 32 | + $CippConfig = Get-CIPPAzDataTableEntity @CippConfigTable -Filter "PartitionKey eq 'InstanceProperties' and RowKey eq 'CIPPURL'" |
| 33 | + $CIPPUrl = 'https://{0}' -f $CippConfig.Value |
| 34 | + |
| 35 | + $AlertData = foreach ($Message in $RequestedReleases) { |
| 36 | + [PSCustomObject]@{ |
| 37 | + Identity = $Message.Identity |
| 38 | + MessageId = $Message.MessageId |
| 39 | + Subject = $Message.Subject |
| 40 | + SenderAddress = $Message.SenderAddress |
| 41 | + RecipientAddress = $Message.RecipientAddress |
| 42 | + Type = $Message.Type |
| 43 | + PolicyName = $Message.PolicyName |
| 44 | + ReleaseStatus = $Message.ReleaseStatus |
| 45 | + ReceivedTime = $Message.ReceivedTime |
| 46 | + QuarantineViewUrl = "$CIPPUrl/email/administration/quarantine?tenantFilter=$TenantFilter" |
| 47 | + Tenant = $TenantFilter |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData |
| 52 | + } |
| 53 | + } catch { |
| 54 | + Write-AlertMessage -tenant $TenantFilter -message "QuarantineReleaseRequests: $(Get-NormalizedError -message $_.Exception.Message)" |
| 55 | + } |
| 56 | +} |
0 commit comments