Skip to content

Commit 358ed97

Browse files
authored
Merge pull request #19 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
2 parents 650780d + ada0f46 commit 358ed97

File tree

7 files changed

+76
-47
lines changed

7 files changed

+76
-47
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Tenant/Invoke-ListTenants.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-ListTenants {
3+
function Invoke-ListTenants {
44
<#
55
.FUNCTIONALITY
66
Entrypoint,AnyTenant
@@ -95,15 +95,15 @@ Function Invoke-ListTenants {
9595
}
9696
if ($Request.Query.Mode -eq 'TenantList') {
9797
# add portal link properties
98-
$Body = $Body | Select-Object *, @{Name = 'portal_m365'; Expression = { "https://admin.microsoft.com/Partner/BeginClientSession.aspx?CTID=$($_.customerId)&CSDEST=o365admincenter" } },
99-
@{Name = 'portal_exchange'; Expression = { "https://admin.exchange.microsoft.com/?landingpage=homepage&form=mac_sidebar&delegatedOrg=$($_.defaultDomainName)" } },
98+
$Body = $Body | Select-Object *, @{Name = 'portal_m365'; Expression = { "https://admin.cloud.microsoft/?delegatedOrg=$($_.initialDomainName)" } },
99+
@{Name = 'portal_exchange'; Expression = { "https://admin.cloud.microsoft/exchange/?delegatedOrg=$($_.initialDomainName)" } },
100100
@{Name = 'portal_entra'; Expression = { "https://entra.microsoft.com/$($_.defaultDomainName)" } },
101-
@{Name = 'portal_teams'; Expression = { "https://admin.teams.microsoft.com/?delegatedOrg=$($_.defaultDomainName)" } },
101+
@{Name = 'portal_teams'; Expression = { "https://admin.teams.microsoft.com/?delegatedOrg=$($_.initialDomainName)" } },
102102
@{Name = 'portal_azure'; Expression = { "https://portal.azure.com/$($_.defaultDomainName)" } },
103103
@{Name = 'portal_intune'; Expression = { "https://intune.microsoft.com/$($_.defaultDomainName)" } },
104104
@{Name = 'portal_security'; Expression = { "https://security.microsoft.com/?tid=$($_.customerId)" } },
105105
@{Name = 'portal_compliance'; Expression = { "https://purview.microsoft.com/?tid=$($_.customerId)" } },
106-
@{Name = 'portal_sharepoint'; Expression = { "https://admin.microsoft.com/Partner/beginclientsession.aspx?CTID=$($_.customerId)&CSDEST=SharePoint" } }
106+
@{Name = 'portal_sharepoint'; Expression = { "/api/ListSharePointAdminUrl?tenantFilter=$($_.defaultDomainName)" } }
107107
}
108108

109109
} else {

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-AuditLogProcessingOrchestrator.ps1

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,52 @@ function Start-AuditLogProcessingOrchestrator {
77
param()
88
Write-Information 'Starting audit log processing in batches of 1000, per tenant'
99
$WebhookCacheTable = Get-CippTable -TableName 'CacheWebhooks'
10-
$WebhookCache = Get-CIPPAzDataTableEntity @WebhookCacheTable
11-
$TenantGroups = $WebhookCache | Group-Object -Property PartitionKey
1210

13-
if ($TenantGroups) {
14-
Write-Information "Processing webhook cache for $($TenantGroups.Count) tenants"
15-
#Write-Warning "AuditLogJobs are: $($TenantGroups.Count) tenants. Tenants: $($TenantGroups.name | ConvertTo-Json -Compress) "
16-
#Write-Warning "Here are the groups: $($TenantGroups | ConvertTo-Json -Compress)"
17-
$ProcessQueue = New-CippQueueEntry -Name 'Audit Logs Process' -Reference 'AuditLogsProcess' -TotalTasks ($TenantGroups | Measure-Object -Property Count -Sum).Sum
18-
$ProcessBatch = foreach ($TenantGroup in $TenantGroups) {
19-
$TenantFilter = $TenantGroup.Name
20-
$RowIds = @($TenantGroup.Group.RowKey)
21-
for ($i = 0; $i -lt $RowIds.Count; $i += 1000) {
22-
Write-Host "Processing $TenantFilter with $($RowIds.Count) row IDs. We're processing id $($RowIds[$i]) to $($RowIds[[Math]::Min($i + 999, $RowIds.Count - 1)])"
23-
$BatchRowIds = $RowIds[$i..([Math]::Min($i + 999, $RowIds.Count - 1))]
24-
[PSCustomObject]@{
25-
TenantFilter = $TenantFilter
26-
RowIds = $BatchRowIds
27-
QueueId = $ProcessQueue.RowKey
28-
FunctionName = 'AuditLogTenantProcess'
11+
$DataTableQuery = @{
12+
First = 20000
13+
Skip = 0
14+
}
15+
16+
do {
17+
$WebhookCache = Get-CIPPAzDataTableEntity @WebhookCacheTable @DataTableQuery
18+
$TenantGroups = $WebhookCache | Group-Object -Property PartitionKey
19+
20+
if ($TenantGroups) {
21+
Write-Information "Processing webhook cache for $($TenantGroups.Count) tenants"
22+
#Write-Warning "AuditLogJobs are: $($TenantGroups.Count) tenants. Tenants: $($TenantGroups.name | ConvertTo-Json -Compress) "
23+
#Write-Warning "Here are the groups: $($TenantGroups | ConvertTo-Json -Compress)"
24+
$ProcessQueue = New-CippQueueEntry -Name 'Audit Logs Process' -Reference 'AuditLogsProcess' -TotalTasks ($TenantGroups | Measure-Object -Property Count -Sum).Sum
25+
$ProcessBatch = foreach ($TenantGroup in $TenantGroups) {
26+
$TenantFilter = $TenantGroup.Name
27+
$RowIds = @($TenantGroup.Group.RowKey)
28+
for ($i = 0; $i -lt $RowIds.Count; $i += 1000) {
29+
Write-Host "Processing $TenantFilter with $($RowIds.Count) row IDs. We're processing id $($RowIds[$i]) to $($RowIds[[Math]::Min($i + 999, $RowIds.Count - 1)])"
30+
$BatchRowIds = $RowIds[$i..([Math]::Min($i + 999, $RowIds.Count - 1))]
31+
[PSCustomObject]@{
32+
TenantFilter = $TenantFilter
33+
RowIds = $BatchRowIds
34+
QueueId = $ProcessQueue.RowKey
35+
FunctionName = 'AuditLogTenantProcess'
36+
}
2937
}
3038
}
31-
}
32-
if ($ProcessBatch) {
33-
$ProcessInputObject = [PSCustomObject]@{
34-
OrchestratorName = 'AuditLogTenantProcess'
35-
Batch = @($ProcessBatch)
36-
SkipLog = $true
39+
if ($ProcessBatch) {
40+
$ProcessInputObject = [PSCustomObject]@{
41+
OrchestratorName = 'AuditLogTenantProcess'
42+
Batch = @($ProcessBatch)
43+
SkipLog = $true
44+
}
45+
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($ProcessInputObject | ConvertTo-Json -Depth 5 -Compress)
46+
Write-Information "Started audit log processing orchestration with $($ProcessBatch.Count) batches"
3747
}
38-
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($ProcessInputObject | ConvertTo-Json -Depth 5 -Compress)
39-
Write-Information "Started audit log processing orchestration with $($ProcessBatch.Count) batches"
4048
}
41-
}
49+
50+
if ($WebhookCache.Count -lt 20000) {
51+
Write-Information 'No more rows to process'
52+
break
53+
}
54+
Write-Information "Processed $($WebhookCache.Count) rows"
55+
$DataTableQuery.Skip += 20000
56+
Write-Information "Getting next batch of $($DataTableQuery.First) rows"
57+
} while ($WebhookCache.Count -eq 20000)
4258
}

Modules/CIPPCore/Public/Entrypoints/Timer Functions/Start-DurableCleanup.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Start-DurableCleanup {
1515

1616
[CmdletBinding(SupportsShouldProcess = $true)]
1717
param(
18-
[int]$MaxDuration = 3600
18+
[int]$MaxDuration = 86400
1919
)
2020

2121
$WarningPreference = 'SilentlyContinue'
@@ -49,6 +49,11 @@ function Start-DurableCleanup {
4949
if ($PSCmdlet.ShouldProcess($_.PartitionKey, 'Terminate Orchestrator')) {
5050
$Orchestrator = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq '$($Orchestrator.PartitionKey)'"
5151
$Orchestrator.RuntimeStatus = 'Failed'
52+
if ($Orchestrator.PSObject.Properties.Name -contains 'CustomStatus') {
53+
$Orchestrator.CustomStatus = "Terminated by Durable Cleanup - Exceeded max duration of $MaxDuration seconds"
54+
} else {
55+
$Orchestrator | Add-Member -MemberType NoteProperty -Name CustomStatus -Value "Terminated by Durable Cleanup - Exceeded max duration of $MaxDuration seconds"
56+
}
5257
Update-AzDataTableEntity @Table -Entity $Orchestrator
5358
$CleanupCount++
5459
}

Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ function Get-CIPPStandards {
2020
$Table = Get-CippTable -tablename 'templates'
2121
$Filter = "PartitionKey eq 'StandardsTemplateV2'"
2222
$Templates = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TimeStamp).JSON |
23-
ForEach-Object {
24-
try {
25-
# Fix old "Action" => "action"
26-
$JSON = $_ -replace '"Action":', '"action":' -replace '"permissionlevel":', '"permissionLevel":'
27-
ConvertFrom-Json -InputObject $JSON -ErrorAction SilentlyContinue
28-
} catch {}
29-
} |
30-
Where-Object {
31-
$_.GUID -like $TemplateId -and $_.runManually -eq $runManually
32-
}
23+
ForEach-Object {
24+
try {
25+
# Fix old "Action" => "action"
26+
$JSON = $_ -replace '"Action":', '"action":' -replace '"permissionlevel":', '"permissionLevel":'
27+
ConvertFrom-Json -InputObject $JSON -ErrorAction SilentlyContinue
28+
} catch {}
29+
} |
30+
Where-Object {
31+
$_.GUID -like $TemplateId -and $_.runManually -eq $runManually
32+
}
3333

3434
# 2. Get tenant list, filter if needed
3535
$AllTenantsList = Get-Tenants
@@ -138,7 +138,15 @@ function Get-CIPPStandards {
138138

139139
if ($template.excludedTenants) {
140140
if ($template.excludedTenants -is [System.Collections.IEnumerable] -and -not ($template.excludedTenants -is [string])) {
141-
$excludedTenantValues = $template.excludedTenants | ForEach-Object { $_.value }
141+
$excludedTenantValues = $template.excludedTenants | ForEach-Object {
142+
$FilterValue = $_.value
143+
if ($_.type -eq 'Group') {
144+
($TenantGroups | Where-Object {
145+
$_.Id -eq $FilterValue
146+
}).Members.defaultDomainName
147+
} else {
148+
$FilterValue
149+
} }
142150
} else {
143151
$excludedTenantValues = @($template.excludedTenants)
144152
}

Modules/CippExtensions/Public/Hudu/Get-HuduFieldMapping.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function Get-HuduFieldMapping {
6868
CIPPFields = $CIPPFields
6969
CIPPFieldHeaders = $CIPPFieldHeaders
7070
IntegrationFields = @($Unset) + @($AssetLayouts)
71-
Mappings = $Mappings
71+
Mappings = @($Mappings)
7272
}
7373

7474
return $MappingObj

Modules/CippExtensions/Public/NinjaOne/Get-NinjaOneFieldMapping.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Get-NinjaOneFieldMapping {
109109
CIPPFields = $CIPPFields
110110
CIPPFieldHeaders = $CIPPFieldHeaders
111111
IntegrationFields = @($Unset) + @($NinjaCustomFieldsOrg) + @($NinjaCustomFieldsNode)
112-
Mappings = $Mappings
112+
Mappings = @($Mappings)
113113
}
114114

115115
return $MappingObj

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.2
1+
7.5.3

0 commit comments

Comments
 (0)