Skip to main content
These scripts manage identities and access policies in Azure Active Directory (now Entra ID). Microsoft has consolidated management under the Microsoft.Graph PowerShell SDK, though the legacy AzureAD module is still widely used in existing environments.
The AzureAD and MSOnline PowerShell modules are deprecated. Microsoft has ended support for these modules. Migrate your scripts to the Microsoft.Graph module to ensure continued compatibility and access to the latest features.

Required modules

Conditional Access policies

Conditional Access policies define the conditions under which users are granted or blocked access to resources. The scripts in AzureAD/ConditionalAccess/ automate reporting and management of these policies.
Managing Conditional Access policies requires the Policy.Read.All and Policy.ReadWrite.ConditionalAccess permission scopes when using Microsoft.Graph.
# Connect with Conditional Access permissions
Connect-MgGraph -Scopes "Policy.Read.All", "Policy.ReadWrite.ConditionalAccess"

# List all Conditional Access policies
Get-MgIdentityConditionalAccessPolicy | 
    Select-Object DisplayName, State, Id

# Get details of a specific policy
Get-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId <PolicyId> | 
    Format-List

# Get only enabled policies
Get-MgIdentityConditionalAccessPolicy -Filter "state eq 'enabled'" | 
    Select-Object DisplayName, State

# Export all CA policies to JSON for backup/documentation
$policies = Get-MgIdentityConditionalAccessPolicy -All
$policies | ConvertTo-Json -Depth 10 | 
    Out-File -FilePath "C:\Reports\ConditionalAccessPolicies.json"
Changes to Conditional Access policies can lock users out of your tenant, including administrators. Always maintain a break-glass account that is excluded from all CA policies, and test policy changes in report-only mode before enabling enforcement.

Build docs developers (and LLMs) love