Skip to content

Commit cdeaa6d

Browse files
Merge pull request KelvinTegelaar#1908 from KelvinTegelaar/dev
Dev to hf
2 parents 31c2350 + beb66f4 commit cdeaa6d

37 files changed

+1340
-184
lines changed

CIPPTimer/function.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
"name": "starter",
1313
"type": "durableClient",
1414
"direction": "in"
15+
},
16+
{
17+
"type": "queue",
18+
"direction": "out",
19+
"name": "QueueItem",
20+
"queueName": "cippqueue"
1521
}
1622
]
1723
}

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertMFAAdmins.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Get-CIPPAlertMFAAdmins {
2323

2424
# Check 1: Admins with no MFA registered — prefer cache, fall back to live Graph
2525
$Users = if ($MFAReport) {
26-
$MFAReport | Where-Object { $_.IsAdmin -eq $true -and $_.MFARegistration -eq $false -and ($IncludeDisabled -or $_.AccountEnabled -eq $true) }
26+
$MFAReport | Where-Object { $_.IsAdmin -eq $true -and $_.MFARegistration -eq $false -and $_.UserType -ne 'Guest' -and ($IncludeDisabled -or $_.AccountEnabled -eq $true) }
2727
} else {
2828
New-GraphGETRequest -uri "https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?`$top=999&filter=IsAdmin eq true and isMfaRegistered eq false and userType eq 'member'&`$select=id,userDisplayName,userPrincipalName,lastUpdatedDateTime,isMfaRegistered,IsAdmin" -tenantid $($TenantFilter) -AsApp $true |
2929
Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' } |
@@ -35,6 +35,7 @@ function Get-CIPPAlertMFAAdmins {
3535
$UnenforcedAdmins = $MFAReport | Where-Object {
3636
$_.IsAdmin -eq $true -and
3737
$_.MFARegistration -eq $true -and
38+
$_.UserType -ne 'Guest' -and
3839
($IncludeDisabled -or $_.AccountEnabled -eq $true) -and
3940
$_.PerUser -notin @('Enforced', 'Enabled') -and
4041
$null -ne $_.CoveredBySD -and

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertMFAAlertUsers.ps1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@ function Get-CIPPAlertMFAAlertUsers {
1111
$TenantFilter
1212
)
1313
try {
14+
$MFAReport = try { Get-CIPPMFAStateReport -TenantFilter $TenantFilter | Where-Object { $_.DisplayName -ne 'On-Premises Directory Synchronization Service Account' } } catch { $null }
15+
16+
$Users = if ($MFAReport) {
17+
$MFAReport | Where-Object { $_.IsAdmin -ne $true -and $_.MFARegistration -eq $false -and $_.UserType -ne 'Guest' -and $_.UPN -notmatch '^package_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}@' }
18+
} else {
19+
New-GraphGETRequest -uri "https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?`$top=999&filter=IsAdmin eq false and isMfaRegistered eq false and userType eq 'member'&`$select=userDisplayName,userPrincipalName,lastUpdatedDateTime,isMfaRegistered,IsAdmin" -tenantid $($TenantFilter) -AsApp $true |
20+
Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' -and $_.userPrincipalName -notmatch '^package_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}@' } |
21+
Select-Object @{n = 'UPN'; e = { $_.userPrincipalName } }, @{n = 'DisplayName'; e = { $_.userDisplayName } }
22+
}
1423

15-
$Users = New-GraphGETRequest -uri "https://graph.microsoft.com/beta/reports/authenticationMethods/userRegistrationDetails?`$top=999&filter=IsAdmin eq false and isMfaRegistered eq false and userType eq 'member'&`$select=userDisplayName,userPrincipalName,lastUpdatedDateTime,isMfaRegistered,IsAdmin" -tenantid $($TenantFilter) -AsApp $true |
16-
Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' -and $_.userPrincipalName -notmatch '^package_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}@' }
1724
if ($Users) {
1825
$AlertData = foreach ($user in $Users) {
1926
[PSCustomObject]@{
20-
UserPrincipalName = $user.userPrincipalName
21-
DisplayName = $user.userDisplayName
22-
LastUpdated = $user.lastUpdatedDateTime
27+
UserPrincipalName = $user.UPN
28+
DisplayName = $user.DisplayName
2329
}
2430
}
2531
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
26-
2732
}
2833

2934
} catch {

Modules/CIPPCore/Public/Compare-CIPPIntuneObject.ps1

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,29 +277,45 @@ function Compare-CIPPIntuneObject {
277277
($Object2 -is [Array] -or $Object2 -is [System.Collections.IList])) {
278278
continue
279279
}
280-
if ($Object1.$propName -and $Object2.$propName) {
281-
Compare-ObjectsRecursively -Object1 $Object1.$propName -Object2 $Object2.$propName -PropertyPath $newPath -Depth ($Depth + 1) -MaxDepth $MaxDepth
280+
$val1 = $Object1.$propName
281+
$val2 = $Object2.$propName
282+
$val1IsEmpty = ($null -eq $val1 -or $val1 -eq '' -or ($val1 -is [Array] -and $val1.Count -eq 0))
283+
$val2IsEmpty = ($null -eq $val2 -or $val2 -eq '' -or ($val2 -is [Array] -and $val2.Count -eq 0))
284+
if ($val1IsEmpty -and $val2IsEmpty) {
285+
# Both empty (null, "", []) - no difference
286+
continue
287+
}
288+
if ($val1 -or $val2) {
289+
Compare-ObjectsRecursively -Object1 $val1 -Object2 $val2 -PropertyPath $newPath -Depth ($Depth + 1) -MaxDepth $MaxDepth
282290
}
283291
} catch {
284292
throw
285293
}
286294
} elseif ($prop1Exists) {
287295
try {
288-
$result.Add([PSCustomObject]@{
296+
$val = $Object1.$propName
297+
$valIsEmpty = ($null -eq $val -or $val -eq '' -or ($val -is [Array] -and $val.Count -eq 0))
298+
if (-not $valIsEmpty) {
299+
$result.Add([PSCustomObject]@{
289300
Property = $newPath
290-
ExpectedValue = $Object1.$propName
301+
ExpectedValue = $val
291302
ReceivedValue = ''
292303
})
304+
}
293305
} catch {
294306
throw
295307
}
296308
} else {
297309
try {
298-
$result.Add([PSCustomObject]@{
310+
$val = $Object2.$propName
311+
$valIsEmpty = ($null -eq $val -or $val -eq '' -or ($val -is [Array] -and $val.Count -eq 0))
312+
if (-not $valIsEmpty) {
313+
$result.Add([PSCustomObject]@{
299314
Property = $newPath
300315
ExpectedValue = ''
301-
ReceivedValue = $Object2.$propName
316+
ReceivedValue = $val
302317
})
318+
}
303319
} catch {
304320
throw
305321
}

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Mailbox Permissions/Push-StoreMailboxPermissions.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,28 @@ function Push-StoreMailboxPermissions {
4040
$ActualResult = $BatchResult[0]
4141
}
4242

43-
if ($ActualResult -and $ActualResult -is [hashtable]) {
43+
if ($ActualResult -and ($ActualResult -is [hashtable] -or $ActualResult -is [System.Collections.IDictionary])) {
4444
Write-Information "Processing hashtable result with keys: $($ActualResult.Keys -join ', ')"
4545
# Results are grouped by cmdlet name due to ReturnWithCommand
4646
if ($ActualResult['Get-MailboxPermission']) {
47-
Write-Information "Adding $($ActualResult['Get-MailboxPermission'].Count) mailbox permissions"
48-
$AllMailboxPermissions.AddRange($ActualResult['Get-MailboxPermission'])
47+
$MailboxPerms = @($ActualResult['Get-MailboxPermission'])
48+
Write-Information "Adding $($MailboxPerms.Count) mailbox permissions"
49+
$AllMailboxPermissions.AddRange($MailboxPerms)
4950
}
5051
if ($ActualResult['Get-RecipientPermission']) {
51-
Write-Information "Adding $($ActualResult['Get-RecipientPermission'].Count) recipient permissions"
52-
$AllRecipientPermissions.AddRange($ActualResult['Get-RecipientPermission'])
52+
$RecipientPerms = @($ActualResult['Get-RecipientPermission'])
53+
Write-Information "Adding $($RecipientPerms.Count) recipient permissions"
54+
$AllRecipientPermissions.AddRange($RecipientPerms)
5355
}
5456
if ($ActualResult['Get-Mailbox']) {
5557
$SendOnBehalfRows = @($ActualResult['Get-Mailbox'])
5658
Write-Information "Adding $($SendOnBehalfRows.Count) send-on-behalf permissions"
5759
$AllSendOnBehalfPermissions.AddRange($SendOnBehalfRows)
5860
}
5961
if ($ActualResult['Get-MailboxFolderPermission']) {
60-
Write-Information "Adding $($ActualResult['Get-MailboxFolderPermission'].Count) calendar permissions"
61-
$AllCalendarPermissions.AddRange($ActualResult['Get-MailboxFolderPermission'])
62+
$CalendarPerms = @($ActualResult['Get-MailboxFolderPermission'])
63+
Write-Information "Adding $($CalendarPerms.Count) calendar permissions"
64+
$AllCalendarPermissions.AddRange($CalendarPerms)
6265
}
6366
} else {
6467
Write-Information "Skipping non-hashtable result: $($ActualResult.GetType().Name)"

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-CIPPDBCacheData.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function Push-CIPPDBCacheData {
116116
if ($ConditionalAccessCapable) {
117117
$ConditionalAccessCacheFunctions = @(
118118
'ConditionalAccessPolicies'
119-
'AuthenticationFlowsPolicy'
119+
#'AuthenticationFlowsPolicy'
120120
'CredentialUserRegistrationDetails'
121121
'UserRegistrationDetails'
122122
)

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Scheduler/Invoke-AddScheduledItem.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ function Invoke-AddScheduledItem {
1515

1616
$DisallowDuplicateName = $Request.Query.DisallowDuplicateName ?? $Request.Body.DisallowDuplicateName
1717

18+
$HeaderProperties = @('x-ms-client-principal', 'x-ms-client-principal-id', 'x-ms-client-principal-name', 'x-forwarded-for')
19+
$Headers = $Request.Headers | Select-Object -Property $HeaderProperties -ErrorAction SilentlyContinue
20+
1821
if ($Request.Body.RunNow -eq $true) {
1922
try {
2023
$Table = Get-CIPPTable -TableName 'ScheduledTasks'
@@ -29,7 +32,7 @@ function Invoke-AddScheduledItem {
2932
Clear = $true
3033
}
3134
$null = Test-CIPPRerun @RerunParams
32-
$Result = Add-CIPPScheduledTask -RowKey $Request.Body.RowKey -RunNow -Headers $Request.Headers
35+
$Result = Add-CIPPScheduledTask -RowKey $Request.Body.RowKey -RunNow -Headers $Headers
3336
} else {
3437
$Result = "Task with id $($Request.Body.RowKey) does not exist"
3538
}
@@ -41,7 +44,7 @@ function Invoke-AddScheduledItem {
4144
} else {
4245
$ScheduledTask = @{
4346
Task = $Request.Body
44-
Headers = $Request.Headers
47+
Headers = $Headers
4548
Hidden = $hidden
4649
DisallowDuplicateName = $DisallowDuplicateName
4750
DesiredStartTime = $Request.Body.DesiredStartTime

0 commit comments

Comments
 (0)