Exporting Power Automate Flow Details using PowerShell

Loading

Exporting Power Automate flow details using PowerShell allows administrators to track, audit, and document automation workflows across environments. This can be useful for compliance, monitoring, and reporting.


Step 1: Install Required PowerShell Modules

Ensure that the necessary Power Automate PowerShell modules are installed:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber
Install-Module -Name Microsoft.PowerApps.PowerShell -Force -AllowClobber

If prompted, press Y to confirm installation.


Step 2: Authenticate to Power Platform

Log in with an admin account to retrieve flow details:

Add-PowerAppsAccount

Alternatively, authenticate via Microsoft Graph:

Connect-MgGraph -Scopes "User.Read.All", "Application.Read.All"

Step 3: List All Power Automate Flows in an Environment

To retrieve all Power Automate flows within a specific environment:

$EnvironmentName = "<EnvironmentID>"  # Replace with your environment ID

Get-AdminFlow -EnvironmentName $EnvironmentName |
Select-Object DisplayName, FlowName, CreatedTime, LastModifiedTime, State |
Format-Table -AutoSize

This command provides:
Flow Name
Creation Date
Last Modified Date
Current State (Enabled/Disabled)


Step 4: Export Flow Details to CSV for Reporting

To save flow details as a CSV file:

$outputPath = "C:\PowerAutomate\FlowDetails.csv"

Get-AdminFlow |
Select-Object EnvironmentName, DisplayName, FlowName, CreatedTime, LastModifiedTime, State |
Export-Csv -Path $outputPath -NoTypeInformation

Write-Host "Power Automate Flow details exported to: $outputPath"

The CSV file will contain:
Environment Name
Flow Name
Creation Date
Last Modified Date
Flow State


Step 5: Export Specific Flow Details (Including Owners and Permissions)

To export detailed flow ownership and permission information:

$EnvironmentName = "<EnvironmentID>"
$FlowName = "<FlowName>"
$outputPath = "C:\PowerAutomate\FlowOwners.csv"

Get-AdminFlowOwner -EnvironmentName $EnvironmentName -FlowName $FlowName |
Select-Object UserId, Role |
Export-Csv -Path $outputPath -NoTypeInformation

Write-Host "Flow ownership details exported to: $outputPath"

This exports:
User ID
Role (Owner/Contributor)


Step 6: Export Flows Based on Status (Enabled/Disabled)

To export only active flows:

$outputPath = "C:\PowerAutomate\ActiveFlows.csv"

Get-AdminFlow | Where-Object { $_.State -eq "Enabled" } |
Select-Object EnvironmentName, DisplayName, FlowName, CreatedTime, LastModifiedTime |
Export-Csv -Path $outputPath -NoTypeInformation

Write-Host "Active Power Automate flows exported to: $outputPath"

🔹 Modify “Enabled” to “Disabled” to export only inactive flows.


Step 7: Export Flows with Connected Services

To export flow details along with connected services (like SharePoint, Outlook, etc.):

$outputPath = "C:\PowerAutomate\FlowConnections.csv"

Get-AdminFlow |
Select-Object EnvironmentName, DisplayName, FlowName, Internal.properties.connectionReferences |
Export-Csv -Path $outputPath -NoTypeInformation

Write-Host "Flow connections exported to: $outputPath"

🔹 This helps in auditing external API dependencies used in Power Automate flows.


Step 8: Disconnect PowerShell Session

After exporting, disconnect the PowerShell session:

Disconnect-MgGraph
Disconnect-PowerAppsAccount

Leave a Reply

Your email address will not be published. Required fields are marked *