File tree Expand file tree Collapse file tree 8 files changed +57
-27
lines changed
Email-Exchange/Spamfilter Expand file tree Collapse file tree 8 files changed +57
-27
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,14 @@ function Get-CIPPAlertNoCAConfig {
1212 )
1313
1414 try {
15- $CAAvailable = (New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/subscribedSkus' - tenantid $TenantFilter - erroraction stop ).serviceplans
15+ $CAAvailable = (New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/subscribedSkus' - tenantid $TenantFilter - ErrorAction Stop ).serviceplans
1616 if (' AAD_PREMIUM' -in $CAAvailable.servicePlanName ) {
1717 $CAPolicies = (New-GraphGetRequest - uri ' https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' - tenantid $TenantFilter )
1818 if (! $CAPolicies.id ) {
1919 $AlertData = ' Conditional Access is available, but no policies could be found.'
2020 Write-AlertTrace - cmdletName $MyInvocation.MyCommand - tenantFilter $TenantFilter - data $AlertData
21-
2221 }
2322 }
24-
2523 } catch {
2624 Write-AlertMessage - tenant $ ($TenantFilter ) - message " Conditional Access Config Alert: Error occurred: $ ( Get-NormalizedError - message $_.Exception.message ) "
2725 }
Original file line number Diff line number Diff line change @@ -11,15 +11,14 @@ function Get-CIPPAlertUnusedLicenses {
1111 $TenantFilter
1212 )
1313
14-
1514 try {
1615 $LicenseTable = Get-CIPPTable - TableName ExcludedLicenses
1716 $ExcludedSkuList = Get-CIPPAzDataTableEntity @LicenseTable
1817 $AlertData = New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/subscribedSkus' - tenantid $TenantFilter | ForEach-Object {
19- $skuid = $_
20- foreach ($sku in $skuid ) {
18+ $skuId = $_
19+ foreach ($sku in $skuId ) {
2120 if ($sku.skuId -in $ExcludedSkuList.GUID ) { continue }
22- $PrettyName = ($ConvertTable | Where-Object { $_.GUID -eq $sku.skuid }).' Product_Display_Name' | Select-Object - Last 1
21+ $PrettyName = ($ConvertTable | Where-Object { $_.GUID -eq $sku.skuId }).' Product_Display_Name' | Select-Object - Last 1
2322 if (! $PrettyName ) { $PrettyName = $sku.skuPartNumber }
2423 if ($sku.prepaidUnits.enabled - $sku.consumedUnits -gt 0 ) {
2524 " $PrettyName has unused licenses. Using $ ( $_.consumedUnits ) of $ ( $_.prepaidUnits.enabled ) ."
Original file line number Diff line number Diff line change @@ -3,9 +3,7 @@ function Push-ExecIncidentsListAllTenants {
33 . FUNCTIONALITY
44 Entrypoint
55 #>
6- param (
7- $Item
8- )
6+ param ($Item )
97
108 $Tenant = Get-Tenants - TenantFilter $Item.customerId
119 $domainName = $Tenant.defaultDomainName
Original file line number Diff line number Diff line change 88 $Tenant = Get-Tenants - TenantFilter $Item.customerId
99 $domainName = $Tenant.defaultDomainName
1010 $Table = Get-CIPPTable - TableName cacheQuarantineMessages
11+ Write-Host " PowerShell queue trigger function processed work item: $ ( $Tenant.defaultDomainName ) "
1112
1213 try {
13- $quarantineMessages = New-ExoRequest - tenantid $domainName - cmdlet ' Get-QuarantineMessage' - cmdParams @ { ' PageSize' = 1000 }
14+ $quarantineMessages = New-ExoRequest - tenantid $domainName - cmdlet ' Get-QuarantineMessage' - cmdParams @ { ' PageSize' = 1000 } | Select-Object - ExcludeProperty * data .type *
1415 $GraphRequest = foreach ($message in $quarantineMessages ) {
15- $GUID = (New-Guid ).Guid
1616 $messageData = @ {
17- QuarantineMessage = [string ]($message | ConvertTo-Json - Depth 10 )
18- RowKey = [string ]$GUID
17+ QuarantineMessage = [string ]($message | ConvertTo-Json - Depth 10 - Compress )
18+ RowKey = [string ]( New-Guid ).Guid
1919 PartitionKey = ' QuarantineMessage'
2020 Tenant = [string ]$domainName
2121 }
2222 Add-CIPPAzDataTableEntity @Table - Entity $messageData - Force | Out-Null
2323 }
2424 } catch {
25- $GUID = (New-Guid ).Guid
2625 $errorData = ConvertTo-Json - InputObject @ {
2726 Identity = $null
2827 ReceivedTime = (Get-Date ).ToString(' s' )
3534 }
3635 $messageData = @ {
3736 QuarantineMessage = [string ]$errorData
38- RowKey = [string ]$GUID
37+ RowKey = [string ]$domainName
3938 PartitionKey = ' QuarantineMessage'
4039 Tenant = [string ]$domainName
4140 }
Original file line number Diff line number Diff line change @@ -20,11 +20,23 @@ function Invoke-ListMailQuarantine {
2020 New-ExoRequest - tenantid $TenantFilter - cmdlet ' Get-QuarantineMessage' - cmdParams @ { ' PageSize' = 1000 } | Select-Object - ExcludeProperty * data .type*
2121 } else {
2222 $Table = Get-CIPPTable - TableName cacheQuarantineMessages
23- $Filter = " PartitionKey eq 'QuarantineMessage'"
23+ $PartitionKey = ' QuarantineMessage'
24+ $Filter = " PartitionKey eq '$PartitionKey '"
2425 $Rows = Get-CIPPAzDataTableEntity @Table - filter $Filter | Where-Object - Property Timestamp -GT (Get-Date ).AddMinutes(-30 )
25- if (! $Rows ) {
26+ $QueueReference = ' {0}-{1}' -f $TenantFilter , $PartitionKey
27+ $RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -notmatch ' Completed' -and $_.Status -notmatch ' Failed' }
28+ # If a queue is running, we will not start a new one
29+ if ($RunningQueue ) {
30+ $Metadata = [PSCustomObject ]@ {
31+ QueueMessage = ' Still loading data for all tenants. Please check back in a few more minutes'
32+ }
33+ [PSCustomObject ]@ {
34+ Waiting = $true
35+ }
36+ } elseif (! $Rows -and ! $RunningQueue ) {
37+ # If no rows are found and no queue is running, we will start a new one
2638 $TenantList = Get-Tenants - IncludeErrors
27- $Queue = New-CippQueueEntry - Name ' Mail Quarantine - All Tenants' - TotalTasks ($TenantList | Measure-Object ).Count
39+ $Queue = New-CippQueueEntry - Name ' Mail Quarantine - All Tenants' - Reference $QueueReference - TotalTasks ($TenantList | Measure-Object ).Count
2840 $Metadata = [PSCustomObject ]@ {
2941 QueueMessage = ' Loading data for all tenants. Please check back in a few minutes'
3042 }
Original file line number Diff line number Diff line change @@ -55,11 +55,23 @@ Function Invoke-ExecAlertsList {
5555 }
5656 } else {
5757 $Table = Get-CIPPTable - TableName cachealertsandincidents
58- $Filter = " PartitionKey eq 'alert'"
59- $Rows = Get-CIPPAzDataTableEntity @Table - filter $Filter | Where-Object - Property Timestamp -GT (Get-Date ).AddHours(-1 )
60- if (! $Rows ) {
58+ $PartitionKey = ' alert'
59+ $Filter = " PartitionKey eq '$PartitionKey '"
60+ $Rows = Get-CIPPAzDataTableEntity @Table - filter $Filter | Where-Object - Property Timestamp -GT (Get-Date ).AddMinutes(-30 )
61+ $QueueReference = ' {0}-{1}' -f $TenantFilter , $PartitionKey
62+ $RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -notmatch ' Completed' -and $_.Status -notmatch ' Failed' }
63+ # If a queue is running, we will not start a new one
64+ if ($RunningQueue ) {
65+ $Metadata = [PSCustomObject ]@ {
66+ QueueMessage = ' Still loading data for all tenants. Please check back in a few more minutes'
67+ }
68+ [PSCustomObject ]@ {
69+ Waiting = $true
70+ }
71+ } elseif (! $Rows -and ! $RunningQueue ) {
72+ # If no rows are found and no queue is running, we will start a new one
6173 $TenantList = Get-Tenants - IncludeErrors
62- $Queue = New-CippQueueEntry - Name ' Alerts List - All Tenants' - TotalTasks ($TenantList | Measure-Object ).Count
74+ $Queue = New-CippQueueEntry - Name ' Alerts List - All Tenants' - Reference $QueueReference - TotalTasks ($TenantList | Measure-Object ).Count
6375 $Metadata = [PSCustomObject ]@ {
6476 QueueMessage = ' Loading data for all tenants. Please check back in a few minutes'
6577 }
Original file line number Diff line number Diff line change @@ -41,11 +41,23 @@ Function Invoke-ExecIncidentsList {
4141 }
4242 } else {
4343 $Table = Get-CIPPTable - TableName cachealertsandincidents
44- $Filter = " PartitionKey eq 'Incident'"
44+ $PartitionKey = ' incident'
45+ $Filter = " PartitionKey eq '$PartitionKey '"
4546 $Rows = Get-CIPPAzDataTableEntity @Table - filter $Filter | Where-Object - Property Timestamp -GT (Get-Date ).AddMinutes(-30 )
46- if (! $Rows ) {
47+ $QueueReference = ' {0}-{1}' -f $TenantFilter , $PartitionKey
48+ $RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -notmatch ' Completed' -and $_.Status -notmatch ' Failed' }
49+ # If a queue is running, we will not start a new one
50+ if ($RunningQueue ) {
51+ $Metadata = [PSCustomObject ]@ {
52+ QueueMessage = ' Still loading data for all tenants. Please check back in a few more minutes'
53+ }
54+ [PSCustomObject ]@ {
55+ Waiting = $true
56+ }
57+ } elseif (! $Rows -and ! $RunningQueue ) {
58+ # If no rows are found and no queue is running, we will start a new one
4759 $TenantList = Get-Tenants - IncludeErrors
48- $Queue = New-CippQueueEntry - Name ' Incidents - All Tenants' - Link ' /security/reports/incident-report?customerId=AllTenants' - TotalTasks ($TenantList | Measure-Object ).Count
60+ $Queue = New-CippQueueEntry - Name ' Incidents - All Tenants' - Link ' /security/reports/incident-report?customerId=AllTenants' - Reference $QueueReference - TotalTasks ($TenantList | Measure-Object ).Count
4961 $Metadata = [PSCustomObject ]@ {
5062 QueueMessage = ' Loading data for all tenants. Please check back in a few minutes'
5163 }
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ function Get-GraphRequestList {
146146 $Type = ' Cache'
147147 Write-Information " Cached: $ ( ($Rows | Measure-Object ).Count) rows (Type: $ ( $Type ) )"
148148 $QueueReference = ' {0}-{1}' -f $TenantFilter , $PartitionKey
149- $RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -ne ' Completed' -and $_.Status -ne ' Failed' }
149+ $RunningQueue = Invoke-ListCippQueue | Where-Object { $_.Reference -eq $QueueReference -and $_.Status -notmatch ' Completed' -and $_.Status -notmatch ' Failed' }
150150 }
151151 }
152152 } catch {
You can’t perform that action at this time.
0 commit comments