Last active
May 28, 2024 10:15
-
-
Save garrytrinder/2f860630b8ef3945954ca922cb99cefc to your computer and use it in GitHub Desktop.
Exports all Power Automate Flows as ZIP files from the default environment using CLI for Microsoft 365
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "Getting environment info..." | |
$environment = m365 flow environment list --query '[?contains(displayName,`default`)] .name' | |
Write-Output "Getting Flows info..." | |
$flows = m365 flow list --environment $environment --asAdmin --output json | ConvertFrom-JSON | |
Write-Output "Found $($flows.Count) Flows to export..." | |
$flows | ForEach-Object { | |
Write-Output "Exporting as ZIP & JSON... $($_.displayName)" | |
$filename = $_.displayName.Replace(" ","") | |
$timestamp = Get-Date -Format "yyyymmddhhmmss" | |
$exportPath = "$($filename)_$($timestamp)" | |
$flowId = $_.Name | |
m365 flow export --id $flowId --environment $environment --packageDisplayName $_.displayName --path "$exportPath.zip" | |
m365 flow export --id $flowId --environment $environment --format json --path "$exportPath.json" | |
} | |
Write-Output "Complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment