Public/TenantConfiguration/Disable-SecurityDefaults.ps1
function Disable-SecurityDefaults() { param( [Parameter(Mandatory)] [string]$TenantId ) Connect-CustomerGraph -CustomerTenantId $TenantId try { $SecurityDefaults = Get-MgPolicyIdentitySecurityDefaultEnforcementPolicy -ErrorAction Stop if($SecurityDefaults.IsEnabled) { Update-MgPolicyIdentitySecurityDefaultEnforcementPolicy -IsEnabled:$false -ErrorAction Stop | Out-Null Write-Host "Security Defaults has been successfully disabled!" -ForegroundColor Green } else { Write-Host "Security Defaults is already disabled, skipping.." -ForegroundColor Yellow } } catch { throw "Failed to disable Security Defaults: $_" } } |