NaveenChalla
NaveenChalla

Reputation: 61

Delete policy using Microsoft Graph Powershell

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

Upvotes: 1

Views: 605

Answers (2)

Venkatesan
Venkatesan

Reputation: 10410

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:

enter image description here

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: enter image description here

Portal: enter image description here

Upvotes: 1

VenkateshDodda
VenkateshDodda

Reputation: 5506

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.

Upvotes: 0

Related Questions