Export All Flow Details to CSV using PowerShell

Introduction

 In this blog, you will see as an administrator how to export all the flow details to CSV using PowerShell.

Prerequisites:

Install the following modules.

  1. Install-Module -Name Microsoft.PowerApps.Administration.PowerShell  
  2. Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber  

You should have appropriate permissions to retrieve all the required information. Refer the following URL to get more information.

https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell#power-automate-commands

PowerShell Script:

Open Notepad and paste the following script. Save the file as script.ps1.

  1. $currentTime=$(get-date).ToString("yyyyMMddHHmmss");    
  2. $outputFilePath=".\results-"+$currentTime+".csv"    
  3. $resultColl=@()   
  4.   
  5. # This call opens prompt to collect credentials (Azure Active Directory account and password) used by the commands   
  6. Add-PowerAppsAccount  
  7.   
  8. # Get all the flows  
  9. write-host -ForegroundColor Magenta "Getting all the flows..."  
  10. $flows=Get-AdminFlow  
  11.   
  12. # Loop through the flows  
  13. foreach($flow in $flows)  
  14. {  
  15.     $result = New-Object PSObject  
  16.     $result | Add-Member -MemberType NoteProperty -name "DisplayName" -value $flow.DisplayName  
  17.     $result | Add-Member -MemberType NoteProperty -Name "CreatedTime" -value $flow.CreatedTime  
  18.     $result | Add-Member -MemberType NoteProperty -Name "LastModifiedTime" -value $flow.LastModifiedTime  
  19.      
  20.     #Add the object with above properties to the Array  
  21.     $resultColl += $result  
  22. }  
  23. #Export the result Array to CSV file  
  24. $resultColl | Export-CSV $outputFilePath -NoTypeInformation  

Open Windows PowerShell window and navigate to the location where the script file was saved.

Run the following command.

.\script.ps1

Result:

Output exported to CSV.

 

Reference:

https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell#power-automate-commands

Summary:

In this blog, you saw how to export all the flow details to CSV using PowerShell.