Skip to content

Commit 035de1e

Browse files
authored
Merge pull request #128 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 80b802a + 8917683 commit 035de1e

File tree

7 files changed

+233275
-29
lines changed

7 files changed

+233275
-29
lines changed

Modules/CIPPCore/Public/Compare-CIPPIntuneObject.ps1

Lines changed: 466 additions & 0 deletions
Large diffs are not rendered by default.

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Transport/Invoke-AddTransportRule.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Function Invoke-AddTransportRule {
2222
try {
2323
if ($Existing) {
2424
Write-Host 'Found existing'
25-
$RequestParams | Add-Member -NotePropertyValue $RequestParams.name -NotePropertyName Identity
25+
$RequestParams | Add-Member -NotePropertyValue $Existing.Identity -NotePropertyName Identity -Force
2626
$null = New-ExoRequest -tenantid $tenantFilter -cmdlet 'Set-TransportRule' -cmdParams ($RequestParams | Select-Object -Property * -ExcludeProperty UseLegacyRegex) -useSystemMailbox $true
2727
"Successfully set transport rule for $tenantFilter."
2828
} else {

Modules/CIPPCore/Public/Get-CIPPIntunePolicy.ps1

Lines changed: 396 additions & 0 deletions
Large diffs are not rendered by default.

Modules/CIPPCore/Public/GraphHelper/New-ExoRequest.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ function New-ExoRequest {
6262
}
6363
}
6464
if (!$Anchor) {
65-
$anchor = "APP:SystemMailbox{bb558c35-97f1-4cb9-8ff7-d53741dc928c}@$($tenant.customerId)"
65+
$MailboxGuid = 'bb558c35-97f1-4cb9-8ff7-d53741dc928c'
66+
if ($cmdlet -in 'Set-AdminAuditLogConfig') {
67+
$MailboxGuid = '8cc370d3-822a-4ab8-a926-bb94bd0641a9'
68+
}
69+
$anchor = "APP:SystemMailbox{$MailboxGuid}@$($tenant.customerId)"
6670
}
6771
#if the anchor is a GUID, try looking up the user.
6872
if ($Anchor -match '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$') {

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardIntuneTemplate.ps1

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,43 @@ function Invoke-CIPPStandardIntuneTemplate {
3232
#>
3333
param($Tenant, $Settings)
3434
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'intuneTemplate'
35-
35+
$Table = Get-CippTable -tablename 'templates'
36+
$Filter = "PartitionKey eq 'IntuneTemplate'"
37+
$Request = @{body = $null }
38+
$Request.body = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property RowKey -Like "$($Settings.TemplateList.value)*").JSON | ConvertFrom-Json
39+
$displayname = $request.body.Displayname
40+
$description = $request.body.Description
41+
$RawJSON = $Request.body.RawJSON
42+
$ExistingPolicy = Get-CIPPIntunePolicy -tenantFilter $Tenant -DisplayName $displayname -TemplateType $Request.body.Type
43+
if ($ExistingPolicy) {
44+
$JSONExistingPolicy = $ExistingPolicy.cippconfiguration | ConvertFrom-Json
45+
$JSONTemplate = $RawJSON | ConvertFrom-Json
46+
$Compare = Compare-CIPPIntuneObject -ReferenceObject $JSONTemplate -DifferenceObject $JSONExistingPolicy -compareType $Request.body.Type
47+
}
3648
If ($Settings.remediate -eq $true) {
37-
3849
Write-Host 'starting template deploy'
3950
Write-Host "The full settings are $($Settings | ConvertTo-Json)"
40-
foreach ($Template in $Settings) {
41-
Write-Host "working on template deploy: $($Template | ConvertTo-Json)"
42-
try {
43-
$Table = Get-CippTable -tablename 'templates'
44-
$Filter = "PartitionKey eq 'IntuneTemplate'"
45-
$Request = @{body = $null }
46-
$Request.body = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Where-Object -Property RowKey -Like "$($Template.TemplateList.value)*").JSON | ConvertFrom-Json
47-
$displayname = $request.body.Displayname
48-
$description = $request.body.Description
49-
$RawJSON = $Request.body.RawJSON
50-
$Template.customGroup ? ($Template.AssignTo = $Template.customGroup) : $null
51-
Set-CIPPIntunePolicy -TemplateType $Request.body.Type -Description $description -DisplayName $displayname -RawJSON $RawJSON -AssignTo $Template.AssignTo -ExcludeGroup $Template.excludeGroup -tenantFilter $Tenant
51+
try {
52+
$Settings.customGroup ? ($Settings.AssignTo = $Settings.customGroup) : $null
53+
Set-CIPPIntunePolicy -TemplateType $Request.body.Type -Description $description -DisplayName $displayname -RawJSON $RawJSON -AssignTo $Settings.AssignTo -ExcludeGroup $Settings.excludeGroup -tenantFilter $Tenant
54+
} catch {
55+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
56+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create or update Intune Template $displayname, Error: $ErrorMessage" -sev 'Error'
57+
}
5258

53-
} catch {
54-
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
55-
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create or update Intune Template $displayname, Error: $ErrorMessage" -sev 'Error'
56-
}
59+
}
60+
61+
if ($Settings.alert) {
62+
#Replace the alert method used in standards with a prettier one, link to the report/template, link to a compare. extended table. etc
63+
if ($compare) {
64+
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Policy $($displayname) does not match the expected configuration." -sev Alert
65+
} else {
66+
$ExistingPolicy ? (Write-LogMessage -API 'Standards' -tenant $Tenant -message "Policy $($displayname) has the correct configuration." -sev Info) : (Write-LogMessage -API 'Standards' -tenant $Tenant -message "Policy $($displayname) is missing." -sev Alert)
5767
}
5868
}
69+
70+
if ($Settings.report) {
71+
#think about how to store this.
72+
Add-CIPPBPAField -FieldName "policy-$displayname" -FieldValue $Compare -StoreAs bool -Tenant $tenant
73+
}
5974
}

Modules/CIPPCore/Public/Test-CIPPGDAPRelationships.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ function Test-CIPPGDAPRelationships {
8383
Type = 'SAM User Membership'
8484
}) | Out-Null
8585
}
86-
if ($CIPPGroupCount -lt 12) {
87-
$GDAPissues.add([PSCustomObject]@{
88-
Type = 'Warning'
89-
Issue = "We only found $($CIPPGroupCount) of the 12 required groups. If you have migrated outside of CIPP this is to be expected. Please perform an access check to make sure you have the correct set of permissions."
90-
Tenant = '*Partner Tenant'
91-
Relationship = 'None'
92-
Link = 'https://docs.cipp.app/setup/gdap/troubleshooting#groups'
86+
}
87+
if ($CIPPGroupCount -lt 12) {
88+
$GDAPissues.add([PSCustomObject]@{
89+
Type = 'Warning'
90+
Issue = "We only found $($CIPPGroupCount) of the 12 required groups. If you have migrated outside of CIPP this is to be expected. Please perform an access check to make sure you have the correct set of permissions."
91+
Tenant = '*Partner Tenant'
92+
Relationship = 'None'
93+
Link = 'https://docs.cipp.app/setup/gdap/troubleshooting#groups'
9394

94-
}) | Out-Null
95-
}
95+
}) | Out-Null
9696
}
9797

9898
} catch {

0 commit comments

Comments
 (0)