Here’s a simple PowerShell script to export all the PowerAutomate workflows from all the environments from Microsoft 365 Tenant using PnP PowerShell.
PnP PowerShell version used: 2.4.63-nightly
#Export all flows available for current user from each environment in Microsoft 365 $siteurl = "https://<tenant>-admin.sharepoint.com" Connect-PnPOnline $siteurl -Interactive Write-Host "Execution Started..." $environments = Get-PnPPowerPlatformEnvironment Write-Output "Total environments: "$environments.length If ($environments.length -gt 0) { $results = @() foreach ($env in $environments) { $flows = Get-PnPFlow -Environment $env.Name -AsAdmin If($flows.length -gt 0){ Write-Host $env.Properties.DisplayName " - " $flows.length " flows found. Exporting flows" foreach($flow in $flows){ $results += [pscustomobject][ordered]@{ EnvironmentID = $env.Name Environment = $env.Properties.DisplayName FlowID = $flow.Name FlowName = $flow.properties.DisplayName Created = $flow.properties.CreatedTime Modified = $flow.properties.LastModifiedTime } } }else{ $results += [pscustomobject][ordered]@{ EnvironmentID = $env.Name Environment = $env.Properties.DisplayName FlowID = "" FlowName = "" Created = "" Modified = "" } Write-Host $env.Properties.DisplayName " - No flows available for the current user!" } } $results | Export-Csv -Path "allenvironmentflows.csv" -NoTypeInformation Write-Host "Export Completed." Write-Host "Execution Completed." }
The above script executes and iterates all the environments and all its flows in admin context. Then it exports in to the csv file in current running path.
The post Export all environments and flows within Microsoft 365 appeared first on KTSKUMAR.COM.