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. # This call opens prompt to collect credentials (Azure Active Directory account and password) used by the commands
  5. Add-PowerAppsAccount
  6. # Get all the flows
  7. write-host -ForegroundColor Magenta "Getting all the flows..."
  8. $flows=Get-AdminFlow
  9. # Loop through the flows
  10. foreach($flow in $flows)
  11. {
  12. $result = New-Object PSObject
  13. $result | Add-Member -MemberType NoteProperty -name "DisplayName" -value $flow.DisplayName
  14. $result | Add-Member -MemberType NoteProperty -Name "CreatedTime" -value $flow.CreatedTime
  15. $result | Add-Member -MemberType NoteProperty -Name "LastModifiedTime" -value $flow.LastModifiedTime
  16. #Add the object with above properties to the Array
  17. $resultColl += $result
  18. }
  19. #Export the result Array to CSV file
  20. $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.