Skip to content

Commit 440aae9

Browse files
authored
Merge pull request #538 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 75091b8 + ab86520 commit 440aae9

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ function Get-CIPPAlertMFAAlertUsers {
44
Entrypoint
55
#>
66
[CmdletBinding()]
7-
Param (
7+
param (
88
[Parameter(Mandatory = $false)]
99
[Alias('input')]
1010
$InputValue,
1111
$TenantFilter
1212
)
1313
try {
1414

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 | Where-Object { $_.userDisplayName -ne 'On-Premises Directory Synchronization Service Account' }
16-
if ($users.UserPrincipalName) {
17-
$AlertData = "The following $($users.Count) users do not have MFA registered: $($users.UserPrincipalName -join ', ')"
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}@' }
17+
if ($Users) {
18+
$AlertData = foreach ($user in $Users) {
19+
[PSCustomObject]@{
20+
UserPrincipalName = $user.userPrincipalName
21+
DisplayName = $user.userDisplayName
22+
LastUpdated = $user.lastUpdatedDateTime
23+
}
24+
}
1825
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
1926

2027
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function Get-CIPPAlertReportOnlyCA {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
# Only consider CA available when a SKU that grants it has enabled seats (> 0)
16+
$SubscribedSkus = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/subscribedSkus?`$select=prepaidUnits,servicePlans" -tenantid $TenantFilter -ErrorAction Stop
17+
$CAAvailable = foreach ($sku in $SubscribedSkus) {
18+
if ([int]$sku.prepaidUnits.enabled -gt 0) { $sku.servicePlans }
19+
}
20+
21+
if (('AAD_PREMIUM' -in $CAAvailable.servicePlanName) -or ('AAD_PREMIUM_P2' -in $CAAvailable.servicePlanName)) {
22+
$CAPolicies = (New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies?$top=999' -tenantid $TenantFilter -ErrorAction Stop)
23+
24+
# Filter for policies in report-only mode
25+
$ReportOnlyPolicies = $CAPolicies | Where-Object { $_.state -eq 'enabledForReportingButNotEnforced' }
26+
27+
if ($ReportOnlyPolicies) {
28+
$PolicyNames = $ReportOnlyPolicies.displayName -join ', '
29+
$AlertData = "The following Conditional Access policies are in report-only mode: $PolicyNames"
30+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
31+
}
32+
}
33+
} catch {
34+
Write-AlertMessage -tenant $($TenantFilter) -message "Report-Only CA Alert: Error occurred: $(Get-NormalizedError -message $_.Exception.message)"
35+
}
36+
37+
}

0 commit comments

Comments
 (0)