To get the most important things out of the way, this can be done only within the first 7 Days.
At times, you want to delete an environment you don’t need. But you feel you do need it back. Deleting an environment from the Power Platform Admin Center will Soft Delete it and you can get it back within the first 7 days only.
Here’s some info by Microsoft on that: https://docs.microsoft.com/en-us/power-platform/admin/backup-restore-environments#how-long-are-my-manualon-demand-backups-and-system-backups-retained
Here’s what we can do within the first 7 days to get it back using PowerShell!
Get PowerShell Support for PowerApps
Before we are able to Run PowerShell directly to recover, you’ll need to get the support for PowerApps in your PowerShell first.
Refer this full Microsoft Documentation for full details: https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell#power-apps-cmdlets-for-administrators-preview
- Open PowerShell and remember to Run it as as Administrator.
- Here’s how you can install the capabilities
Here are the 2 commands which I used in the screenshots above in PowerShell. Below is the screenshot I took from Microsoft Docs so that you can visualize how the commands look
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
or if you don’t have Admin Access, below code can be used in PowerShell
Save-Module -Name Microsoft.PowerApps.Administration.PowerShell -Path
Import-Module -Name Microsoft.PowerApps.Administration.PowerShell
Save-Module -Name Microsoft.PowerApps.PowerShell -Path
Import-Module -Name Microsoft.PowerApps.PowerShell
4. Now, let’s say you are all set to execute your recovery process.
Recovery of Environment
Assuming you have completed the above steps, you can now proceed towards recovering the environment.
- Now, in PowerShell, run the below command “
- You’ll be directed to a Login screen. Enter environment credentials there.
- You’ll get the Deleted environments’s details as below. In my case, only 1 Deleted environment was retrieved
Note the first line i.e. EnvironmentName. Copy that GUID
- Next, run the below command after you copied the GUID –
Recover-AdminPowerAppEnvironment -EnvironmentName 35545668-80c2-4d88-811d-b698bb1bcf59 -WaitUntilFinished $true
- Once completed, you won’t see any message but the cursor will be on the new line ready. And some details about the success of the operation.
- And in the Admin Center, the environment will be recovered.
Hope this helps!!
Here are some more Power Platform related posts you might want to check –