65.9K
CodeProject 正在变化。 阅读更多。
Home

如何更改 PowerApp 的所有者

2020年6月22日

CPOL

1分钟阅读

viewsIcon

15697

本技巧解释如何在 Office 365 中更改 PowerApp 的所有者。

引言

PowerApps 是微软在 Office 365 环境中提供的无代码解决方案。即使没有开发背景的用户,也可以使用 PowerApp 自定义 SharePoint 列表,或者毫不费力地创建画布应用来满足他们的业务需求。

背景

创建 PowerApp 的用户将成为该应用的默认所有者。所有者始终可以选择将其他用户设置为应用的所有者。但很多时候,所有者并没有将其他人设置为其应用的所有者。由于 PowerApp 与所有者的用户配置文件相关联,一旦所有者离开组织或其 O365 ID 被禁用,PowerApps 将被系统自动删除。

在管理环境中,将不同用户设置为 PowerApp 的所有者是一个非常常见的挑战性场景。如果您不是应用的所有者或共同所有者,则无法编辑 PowerApp。

本文档解释了如何管理这种情况。

Using the Code

首先,您需要找到 PowerApp 的名称或 ID。请按照以下步骤操作:

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

现在获取新所有者的 ID,例如“test.user_2@test123.onmicrosoft.com”,请按照以下步骤操作:

Connect-AzureAD

$userId = Get-AzureADUser -ObjectId "test.user_2@test123.onmicrosoft.com"

使用 Set-AdminPowerAppOwner 命令来转移 PowerApp 的所有权,请尝试以下步骤:

Set-AdminPowerAppOwner –AppName $apps.AppName -AppOwner $userId –EnvironmentName $envname

现在 $app 的所有者已更改为新所有者,您可以使用以下命令进行验证:

#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

关注点

这将帮助管理员在其环境中转移 PowerApps 的所有权。

参考

历史

  • 2020 年 6 月 22 日:初始版本
© . All rights reserved.