Skip to main content

Export Condentional Access Rules

Export der JSON Dateien per Powershell

 

 

# Connect to your source tenant
Connect-AzureAD

# Define the folder where you want to export the rules
$exportPath = "C:\ConditionalAccessExport"

# Create the export folder if it doesn't exist
if (-not (Test-Path -Path $exportPath)) {
    New-Item -Path $exportPath -ItemType Directory
}

# Get all conditional access policies
$conditionalAccessPolicies = Get-AzureADMSConditionalAccessPolicy

# Export each policy as a JSON file
foreach ($policy in $conditionalAccessPolicies) {
    $policyJson = $policy | ConvertTo-Json -Depth 10

    $exportFileName = Join-Path -Path $exportPath -ChildPath "$($policy.DisplayName).json"
    $policyJson | Set-Content -Path $exportFileName
}

# Disconnect from the source tenant
Disconnect-AzureAD