Skip to content

Instantly share code, notes, and snippets.

@garrytrinder
Last active May 25, 2018 10:03
Show Gist options
  • Save garrytrinder/1f711be2f895c5d423dd6c69868f5c17 to your computer and use it in GitHub Desktop.
Save garrytrinder/1f711be2f895c5d423dd6c69868f5c17 to your computer and use it in GitHub Desktop.
Script that updates the Owner of a PowerApp
# Requires Azure Powershell
# https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-6.1.0
# Requires PowerShell support for PowerApps (preview)
# https://docs.microsoft.com/en-us/powerapps/administrator/powerapps-powershell
# Step 1 - Setup PowerShell support for PowerApps
Import-Module .\Microsoft.PowerApps.Administration.PowerShell.psm1 -Force
Import-Module .\Microsoft.PowerApps.PowerShell.psm1 -Force
Get-ChildItem . | Unblock-File
# Step 2 - Get Azure AD User
Login-AzureRmAccount
$user = Get-AzureRmADUser -UserPrincipalName "user@tenant.onmicrosoft.com"
Disconnect-AzureRmAccount
# Step 3 - Update PowerApp Owner
Add-PowerAppsAccount
$env = Get-AdminEnvironment *Default*
$app = Get-App *MyApp*
Set-AdminAppOwner -AppName $app.AppName -AppOwner $user.Id -EnvironmentName $env.EnvironmentName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment