How to Get All the Flows from a Specific Environment using PowerShell

Introduction 

In this blog, you will see as an administrator how to get all the flows that contain specific characters (for example, test) from a specific environment using PowerShell.

Prerequisites

Install the following modules.

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

PowerShell Script

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

  1. # Input Parameters  
  2. $envDispName='Finance Prod'  
  3.  
  4. # This call opens prompt to collect credentials (Azure Active Directory account and password) used by the commands   
  5. Add-PowerAppsAccount  
  6.  
  7. # Get the specific environment  
  8. $env=Get-AdminPowerAppEnvironment -ErrorAction SilentlyContinue| Where-Object {$_.DisplayName -eq $envDispName}  
  9. $envName=$env.EnvironmentName  
  10.  
  11. # Get all the flows from specific environment which contains the display name as test  
  12. write-host -ForegroundColor Magenta "Getting flows from environment: " $env.DisplayName  
  13. $flows=Get-AdminFlow *test* -EnvironmentName $envName  
  14.  
  15. # Loop through the flows and display teh values  
  16. foreach($flow in $flows)  
  17. {  
  18.     write-host -ForegroundColor Green "Flow Name: " $flow.FlowName " Display Name: " $flow.DisplayName " Created Time: " $flow.CreatedTime  
  19. }   

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

Run the following command.

.\script.ps1

 

Reference

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

Summary

In this blog, you saw how to get all the flows which contain specific characters from a specific environment using PowerShell.