Restore Deleted Flows with PowerShell

Prerequisites for PowerShell

  • You must install the latest version of PowerShell cmdlets for Power Apps.
  • You must be an environment admin.
  • An execution policy must be set on your device to run PowerShell scripts.

Step 1. Open PowerShell with elevated privileges to begin.

PowerShell

Step 2. Install the latest version of PowerShell cmdlets for Power Apps.

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -RequiredVersion 2.0.147

Latest version

Step 3. Sign in to your Power Apps environment.

Use this command to authenticate to an environment. This command opens a separate window that prompts for your Microsoft Entra authentication details.

Add-PowerAppsAccount

Step 4. Provide the credentials you want to use to connect to your environment.

Step 5. Run the following script to get a list of flows in the environment, including flows that were soft-deleted within the past 21 days. If the IncludeDeleted parameter isn't recognized, you might be working with an older version of the PowerShell scripts.

Get-AdminFlow -EnvironmentName <Your Environment ID> -IncludeDeleted $true

PowerShell scripts

Step 6. Make a note of the FlowName value of the flow you want to restore from the previous step.

Step 7. You can filter the list of flows if you know part of the name of the deleted flow whose flowID you want to find.

Get-AdminFlow <Flow Name>  -EnvironmentName <Environment ID> -IncludeDeleted $true

Step 8. Run the following script to restore the soft-deleted flow with the FlowName value.

Restore-AdminFlow -EnvironmentName <Environment ID>  -FlowName <Flow ID> 

Script

After a Successful run, the flow will be restored. This flow was deleted and restored.

Successful run

Note

  • The steps in this article apply to both non-solution and solution flows.
  • Flows that were deleted more than 21 days ago can't be recovered. Both restore methods (PowerShell script and Power Automate Management connector), as well as Microsoft Support can't help to restore them.
  • After you restore a flow, it defaults to the disabled state. You must manually enable the flow, per your requirements.


Similar Articles