
The other alternative you could use is :
To validate if security default is enabled or not:
Connect-MgGraph -Scopes Policy.ReadWrite.ConditionalAccess, Policy.Read.All
Get-MgPolicyIdentitySecurityDefaultEnforcementPolicy | select IsEnabled
To enable it use the following command:
$params = @{
IsEnabled = $true
}
Update-MgPolicyIdentitySecurityDefaultEnforcementPolicy -BodyParameter $params
To disable it use the following command:
$params = @{
IsEnabled = $true
}
Update-MgPolicyIdentitySecurityDefaultEnforcementPolicy -BodyParameter $params
Please do let me know if you have any queries in the comments.
Thanks,
Akshay Kaushik
Please "Accept the answer" (Yes), and share your feedback if the suggestion answers you’re your query. This will help us and others in the community as well.