Blog

General - How to undelete or restore deleted apps

Have you or someone in your company ever accidentally deleted a canvas app? In this situation, there's no need to worry! We can restore deleted apps with PowerShell and in this post, we'll walk through how.

Provided that we have administrative permissions on an environment, it's possible to undelete apps that users have deleted. Here's a walk through of the steps to carry out this task.

Prerequisites

A prerequisite is to install the PowerShell Cmdlets for Power Apps. We can find more details in the documentation here:

Documentation for Cmdlet

Once we install the Cmdlets, we can open PowerShell and login to our Power Apps environment.

Here's the command to authenticate to an environment. This will open separate window that prompts for our AAD authentication details.
Add-PowerAppsAccount

As with most Cmdlets, we can call Get-Help for help. We can pass the Examples switch for example usage, or the Detailed switch for a full explaination of a command.

Get-Help Get-AdminDeletedPowerAppsList -Examples
Get-Help Get-AdminDeletedPowerAppsList -Detailed

Here's the result when we call Get-Help on the Get-AdminDeletedPowerAppsList Cmdlet with the Examples switch. This is the command that we'll use to show a list of deleted apps.

Retrieving a list of deleted apps

To retrieve a list of recoverable apps, we run Get-AdminDeletedPowerAppsList with the following arguments like so:

Get-AdminDeletedPowerAppsList -EnvironmentName Default-df7b308b-854f-4f83-bb6b-bcee961c8b22

This Cmdlet requires us to pass an EnvironmentName argument. We can determine this value by inspecting the address of the Maker Portal. Note that the environment name isn't necessarily an exact GUID. With the default environment in this example, notice how the GUID is prefixed with the value "Default-".


The result of this command returns the GUID AppNames of the apps that we can recover.

Recovering an app

Once we determine the app that we want to restore, we run the following Cmdlet.

Get-AdminRecoverDeletedPowerApp 
-EnvironmentName Default-df7b308b-854f-4f83-bb6b-bcee961c8b22
-AppName 35afae3e-8507-47e7-9b52-288269f0720b

The screenshot beneath shows what we see when this command succeeds. We should receive a 200 sucess message.

At this stage, we can return to the Maker Portal and the app that we restored should appear in the app list. The name of the app will be suffixed with a description that indicates the restoration date.

Conclusion

In cases where users accidentally delete an app, we can restore the app by running a PowerShell command. In this post, we walked through this process.