Recover Deleted MS Flows.

Recover Deleted MS Flows.

If a non-solution or solution flow is accidentally deleted by you or someone else, it can be restored within 21 days of its deletion.

2 Ways to Restore (MS Flows Connecter and Power Shell)

Restore deleted flows with the Power Automate Management connector

Using Power Automate, you have the capability to restore a deleted solution flow or non-solution flow within a 21-day window after deletion. A non-solution flow refers to a flow that was not initially created within a solution.

As an administrator, you can achieve this by creating a button flow containing two crucial

Power Automate management connector actions: List Flows as Admin and Restore Deleted Flows as Admin.

As part of this process, in four easy and quick steps, you'll first list deleted flows in an environment using the List flows as Admin action. Then, you'll use the Restore Deleted Flows as Admin action to restore the flow using flowName property of the flow that you retrieved from the List flows as Admin action.

1) Build a manual flow with a button trigger.

Manually Trigger a Flow

2) Add the List Flows as Admin action.

  1. Select New Step.
  2. Search for Power Automate Management Connector or List Flows as Admin action.
  3. Select the List Flows as Admin action.
  4. In the Environment dropdown menu, select the environment the flow was originally deleted from.
  5. In the Include Soft-Deleted Flows dropdown menu, select Yes

List Flows as Admin

3) Run the flow to note the flowName of the flow you want to retrieve.

  1. Run the flow.
  2. Expand the flow run.
  3. Expand the raw OUTPUTS/value of the List Flows as Admin action.You'll see all the flows in that environment you have access to as an admin, including the ones that are soft deleted.
  4. Using the "displayName" among other flow metadata, identify the flow you're trying to recover and note the name in "name" field.In the following screenshot, the name of the flow is highlighted in green. You'll use this value for the next step.

4) Add the Restore Deleted Flows as Admin action and run the flow.

  1. Add the Restore Deleted Flows as Admin action from the Power Automate Management Connector.
  2. In the Flow field, enter the name value from step 3.

3. Run the flow.

After the run has succeeded, you'll notice that the flow has been restored in a disabled state in the environment it was originally deleted from.

Restore deleted flows with PowerShell

In this section, you'll learn about how to restore deleted flows using PowerShell.

Prerequisites for PowerShell

1) Open PowerShell with elevated privileges to begin.


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

3) Sign in to your Power Apps environment.

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

Add-PowerAppsAccount        

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

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. Ensure that you're using the latest version of the script modules and retry the steps.

Get-AdminFlow -EnvironmentName 41a90621-d489-4c6f-9172-81183bd7db6c -IncludeDeleted $true
//To view examples: Get-Help Get-AdminFlow -Examples        
Note: Navigate to the URL of any of the flows in your environment to get your environment name (https://make.powerautomate.com/Environments/<EnvironmentName>/flows) which is required for subsequent steps. Don't omit the prefixed words in the URL if your environment name contains it, for example, Default-8ae09283902-..

6. Optionally, you can filter the list of flows if you know part of the name of the deleted flow whose flowID you want to find.

To do this, use a script similar to this one that finds all flows (including flows that were soft-deleted) in environment 3c2f7648-ad60-4871-91cb-b77d7ef3c239 that contain the string "Testing" in their display name. 256fe2cd306052f68b89f96bc6be643
Get-AdminFlow Testing -EnvironmentName 3c2f7648-ad60-4871-91cb-b77d7ef3c239 -IncludeDeleted $true        

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

8) Run the following script to restore the soft-deleted flow with FlowName value as 4d1f7648-ad60-4871-91cb-b77d7ef3c239 in an environment named Default-55abc7e5-2812-4d73-9d2f-8d9017f8c877.

Restore-AdminFlow -EnvironmentName Default-55abc7e5-2812-4d73-9d2f-8d9017f8c877 -FlowName 4d1f7648-ad60-4871-91cb-b77d7ef3c239
 //To view examples: Get-Help Restore-AdminFlow -Examples        

9) Optionally, you can run the Restore-AdminFlow script with the following arguments to restore multiple deleted flows.

foreach ($id in @( "4d1f7648-ad60-4871-91cb-b77d7ef3c239", "eb2266a8-67b6-4919-8afd-f59c3c0e4131" )) { Restore-AdminFlow -EnvironmentName Default-55abc7e5-2812-4d73-9d2f-8d9017f8c877 -FlowName $id; Start-Sleep -Seconds 1 }        

Conclusion:

If you or someone else accidentally deletes a non-solution or solution flow, you can restore it within 21 days of deletion.

要查看或添加评论,请登录

Shafiuddin Mohammed的更多文章

社区洞察

其他会员也浏览了