Skip to content

Commit 4b4018d

Browse files
SecDefaultsDisabled
1 parent acaab51 commit 4b4018d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function Get-CIPPAlertSecDefaultsDisabled {
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+
# Check if Security Defaults is disabled
16+
$SecDefaults = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/identitySecurityDefaultsEnforcementPolicy' -tenantid $TenantFilter)
17+
18+
if ($SecDefaults.isEnabled -eq $false) {
19+
# Security Defaults is disabled, now check if there are any CA policies
20+
$CAPolicies = (New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' -tenantid $TenantFilter)
21+
22+
if (!$CAPolicies -or $CAPolicies.Count -eq 0) {
23+
# Security Defaults is off AND no CA policies exist
24+
$AlertData = [PSCustomObject]@{
25+
Message = 'Security Defaults is disabled and no Conditional Access policies are configured. This tenant has no baseline security protection.'
26+
Tenant = $TenantFilter
27+
}
28+
29+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
30+
}
31+
}
32+
} catch {
33+
Write-AlertMessage -tenant $($TenantFilter) -message "Security Defaults Disabled Alert: Error occurred: $(Get-NormalizedError -message $_.Exception.message)"
34+
}
35+
}

0 commit comments

Comments
 (0)