I want to delete conditional access policy from Microsoft Graph Powershell.
I found this to do from Graph api
DELETE https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/{id}
But how to find the command for this in Microsoft Graph Powershell.
PS: I connected to Graph from Powershell with Connect-MgGraph
TIA
CodePudding user response:
You can use this Remove-MgIdentityConditionalAccessPolicy
cmdlet to remove the conditional access policy.
Remove-MgIdentityConditionalAccessPolicy
-ConditionalAccessPolicyId <String>
[-IfMatch <String>]
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Refer to this documentation to know more about the cmdlet and also the accepted input values to those parameters.
Here is the MG graph PowerShell cmdlets documentation.
CodePudding user response:
I tried in my environment and got below results:
Initially I have an conditional policy like Require MFA to user administrator
in my portal.
Portal:
Commands: I tried with below commands and I removed a conditional policy successfully.
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess', 'Policy.Read.All'
Get-MgIdentityConditionalAccessPolicy
$conditionalAccessPolicyId="Id"
Remove-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId $conditionalAccessPolicyId
Console:
Portal: