Public/Disable-SecurityDefaults.ps1

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