Skip to content

Commit 1deaddb

Browse files
authored
Merge pull request #1016 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 49bf00e + 8f2198e commit 1deaddb

4 files changed

Lines changed: 54 additions & 48 deletions

File tree

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

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ function Get-CIPPStandards {
2626
# can compute correct precedence. The $TemplateId filter is applied after merge so that
2727
# manual runs of a single template don't bypass tenant-specific overrides.
2828
$Templates = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TimeStamp).JSON |
29-
ForEach-Object {
30-
try {
31-
# Fix old "Action" => "action"
32-
$JSON = $_ -replace '"Action":', '"action":' -replace '"permissionlevel":', '"permissionLevel":'
33-
ConvertFrom-Json -InputObject $JSON -ErrorAction SilentlyContinue
34-
} catch {}
35-
} |
36-
Where-Object {
37-
$_.runManually -eq $runManually
29+
ForEach-Object {
30+
try {
31+
# Fix old "Action" => "action"
32+
$JSON = $_ -replace '"Action":', '"action":' -replace '"permissionlevel":', '"permissionLevel":'
33+
ConvertFrom-Json -InputObject $JSON -ErrorAction SilentlyContinue
34+
} catch {}
35+
} |
36+
Where-Object {
37+
$_.runManually -eq $runManually
38+
}
39+
40+
if ($TemplateId -ne '*' -and ![string]::IsNullOrEmpty($TemplateId)) {
41+
$Templates = $Templates | Where-Object {
42+
$_.GUID -like $TemplateId
43+
}
3844
}
3945

4046
# 1.5. Expand templates that contain TemplateList-Tags into multiple standards
@@ -50,35 +56,35 @@ function Get-CIPPStandards {
5056

5157
if ($IsArray) {
5258
$NewArray = @(foreach ($Item in $StandardValue) {
53-
if ($Item.'TemplateList-Tags'.value) {
54-
$HasExpansions = $true
55-
$Table = Get-CippTable -tablename 'templates'
56-
$PartitionKey = switch ($StandardName) {
57-
'ConditionalAccessTemplate' { 'CATemplate' }
58-
'IntuneTemplate' { 'IntuneTemplate' }
59-
default { 'IntuneTemplate' }
60-
}
61-
$Filter = "PartitionKey eq '$PartitionKey'"
62-
$TemplatesList = Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property package -EQ $Item.'TemplateList-Tags'.value
63-
Write-Information "Expanding $StandardName tag '$($Item.'TemplateList-Tags'.value)' from partition '$PartitionKey': found $(@($TemplatesList).Count) templates"
64-
65-
foreach ($TemplateItem in $TemplatesList) {
66-
$TemplateJSON = $TemplateItem.JSON | ConvertFrom-Json -Depth 100 -ErrorAction SilentlyContinue
67-
$TemplateLabel = if ($TemplateJSON.displayName) { $TemplateJSON.displayName } else { "$($TemplateItem.RowKey)" }
68-
$NewItem = $Item.PSObject.Copy()
69-
$NewItem.PSObject.Properties.Remove('TemplateList-Tags')
70-
$NewItem | Add-Member -NotePropertyName TemplateList -NotePropertyValue ([pscustomobject]@{
71-
label = $TemplateLabel
72-
value = "$($TemplateItem.RowKey)"
73-
}) -Force
74-
$NewItem | Add-Member -NotePropertyName TemplateId -NotePropertyValue $Template.GUID -Force
75-
$NewItem
59+
if ($Item.'TemplateList-Tags'.value) {
60+
$HasExpansions = $true
61+
$Table = Get-CippTable -tablename 'templates'
62+
$PartitionKey = switch ($StandardName) {
63+
'ConditionalAccessTemplate' { 'CATemplate' }
64+
'IntuneTemplate' { 'IntuneTemplate' }
65+
default { 'IntuneTemplate' }
66+
}
67+
$Filter = "PartitionKey eq '$PartitionKey'"
68+
$TemplatesList = Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property package -EQ $Item.'TemplateList-Tags'.value
69+
Write-Information "Expanding $StandardName tag '$($Item.'TemplateList-Tags'.value)' from partition '$PartitionKey': found $(@($TemplatesList).Count) templates"
70+
71+
foreach ($TemplateItem in $TemplatesList) {
72+
$TemplateJSON = $TemplateItem.JSON | ConvertFrom-Json -Depth 100 -ErrorAction SilentlyContinue
73+
$TemplateLabel = if ($TemplateJSON.displayName) { $TemplateJSON.displayName } else { "$($TemplateItem.RowKey)" }
74+
$NewItem = $Item.PSObject.Copy()
75+
$NewItem.PSObject.Properties.Remove('TemplateList-Tags')
76+
$NewItem | Add-Member -NotePropertyName TemplateList -NotePropertyValue ([pscustomobject]@{
77+
label = $TemplateLabel
78+
value = "$($TemplateItem.RowKey)"
79+
}) -Force
80+
$NewItem | Add-Member -NotePropertyName TemplateId -NotePropertyValue $Template.GUID -Force
81+
$NewItem
82+
}
83+
} else {
84+
$Item | Add-Member -NotePropertyName TemplateId -NotePropertyValue $Template.GUID -Force
85+
$Item
7686
}
77-
} else {
78-
$Item | Add-Member -NotePropertyName TemplateId -NotePropertyValue $Template.GUID -Force
79-
$Item
80-
}
81-
})
87+
})
8288
if ($NewArray.Count -gt 0) {
8389
$ExpandedStandards[$StandardName] = $NewArray
8490
}

Modules/CIPPCore/Public/Test-CIPPRerun.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ function Test-CIPPRerun {
6262
$NewSettings = $($Settings | ConvertTo-Json -Depth 10 -Compress)
6363
if ($NewSettings.Length -ne $PreviousSettings.Length) {
6464
Write-Host "$($NewSettings.Length) vs $($PreviousSettings.Length) - settings have changed."
65-
$RerunData.EstimatedNextRun = $EstimatedNextRun
66-
$RerunData.LastScheduledTime = "$CurrentUnixTime"
67-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
65+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
66+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$CurrentUnixTime" -Force
67+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
6868
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
6969
return $false # Not a rerun because settings have changed.
7070
}
@@ -73,19 +73,19 @@ function Test-CIPPRerun {
7373
# treat it as a new execution rather than a duplicate.
7474
if ($BaseTime -gt 0 -and $RerunData.LastScheduledTime -and [int64]$RerunData.LastScheduledTime -ne $BaseTime) {
7575
Write-Information "Task $API has a new ScheduledTime ($BaseTime vs cached $($RerunData.LastScheduledTime)). Treating as new execution."
76-
$RerunData.EstimatedNextRun = $EstimatedNextRun
77-
$RerunData.LastScheduledTime = "$BaseTime"
78-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
76+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
77+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$BaseTime" -Force
78+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
7979
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
8080
return $false
8181
}
8282
if ($RerunData.EstimatedNextRun -gt $CurrentUnixTime) {
8383
Write-LogMessage -API $API -message "$Type rerun detected for $($API). Prevented from running again." -tenant $TenantFilter -headers $Headers -Sev 'Info'
8484
return $true
8585
} else {
86-
$RerunData.EstimatedNextRun = $EstimatedNextRun
87-
$RerunData.LastScheduledTime = "$BaseTime"
88-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
86+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
87+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$BaseTime" -Force
88+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
8989
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
9090
return $false
9191
}

host.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"distributedTracingEnabled": false,
1717
"version": "None"
1818
},
19-
"defaultVersion": "10.5.1",
19+
"defaultVersion": "10.5.2",
2020
"versionMatchStrategy": "Strict",
2121
"versionFailureStrategy": "Fail"
2222
}

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.5.1
1+
10.5.2

0 commit comments

Comments
 (0)