There is a very common scenario in the Admin world where you have to change the owner of the PowerApp. This mainly occurs when the creator or owner of the App is moved out of the organization. There is no way to edit the PowerApp if you are not the owner or co-owner of the App.
Introduction
PowerApps is the emerging no code solution provided by Microsoft in the Office 365 world. Users with no development background will be able to customize the SharePoint list using PowerApp or create a Canvas app without much effort to meet their business needs.
Background
The user who creates PowerApp will be the default owner of the app. The owner always has an option to set other users as owner of the app. But many times, owners don't set others as owners of their app. Since the PowerApp is associated to the user profile of the owner, PowerApps will be deleted automatically by the system once the owner moves out of the organization or his/her O365 ID gets disabled.
This is a very common challenging scenario in the Admin world to set different user(s) as the owner of the PowerApp. There is no way to edit the PowerApp if you are not the owner or co-owner of the App.
This post explains how to manage the situation .
Using the Code
First of all, you need to find out the PowerApp Name or ID. Follow the below steps:
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
#Set variable for your tenant ID
$envname="Default-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
#This is the user to connect to the environment. Make sure it has Admin rights.
$User = "test.user@test123.onmicrosoft.com"
$pass = ConvertTo-SecureString "xxxxxxxx" -AsPlainText -Force
#Connect to the environment
Add-PowerAppsAccount -Username $User -Password $pass
#Get the details of a particular App by name (TestApp-DEV is the name of the App)
$apps = Get-AdminPowerApp | Where-Object {$_.DisplayName -like 'TestApp-DEV'}
#This shows the App ID of the PowerApp
Write-Host $apps.AppName
Now get the Id of the new owner, "test.user_2@test123.onmicrosoft.com
", follow the below steps:
Connect-AzureAD
$userId = Get-AzureADUser -ObjectId "test.user_2@test123.onmicrosoft.com"
Use the Set-AdminPowerAppOwner
command to transfer the ownership of the PowerApp, try the below step.
Set-AdminPowerAppOwner –AppName $apps.AppName -AppOwner $userId –EnvironmentName $envname
Now the owner of the $app
is changes to new owner, you can verify it by using the below commands:
#Get the details of a particular App by name (TestApp-DEV is the name of the App)
$apps = Get-AdminPowerApp | Where-Object {$_.DisplayName -like 'TestApp-DEV'}
Write-Host $apps.Owner
Points of Interest
This will help admins to transfer the ownership of the PowerApps in their environments.
Reference
History
- 22nd June, 2020: Initial version