開始使用 Power Platform 管理員的 PowerShell

用於 Power Platform 的 PowerShell 的 管理員 cmdlet 設計可用於管理 Microsoft Power Platform 環境、Power Apps 和 Power Automate 流程。 當您要建構與這些資源進行互動的自動化工具時,請使用 Power Platform 系統管理員的 PowerShell。

本文章可幫助您開始使用 PowerShell 模組並講授其背後的核心概念。

安裝

開始使用 PowerShell 模組的最簡單方法就是將其安裝在本地機器上。 請按照安裝指示匯入模組,或更新以前可能已安裝過的舊版版本。

登入 Microsoft Power Platform

使用 Add-PowerAppsAccount cmdlet 互動式登入。

Add-PowerAppsAccount -Endpoint prod

或者,您可以使用客戶端 ID 和密碼或憑證登入。 為此,您必須建立服務主體

$appId = "CLIENT_ID_FROM_AZURE_APP"
$secret = "SECRET_FROM_AZURE_APP"
$tenantId = "TENANT_ID_FROM_AZURE_APP"

Add-PowerAppsAccount -Endpoint prod -TenantID $tenantId -ApplicationId $appId -ClientSecret $secret -Verbose

先決條件

若要在 Cmdlet 中執行系統管理作業,您需要有:

  • Azure Active Directory、租用戶管理員、Power Platform 系統管理員或 Dynamics 365 服務管理員這些角色中的任何一個都可以存取 Power Apps 管理員 PowerShell Cmdlet。 這些角色不再需要 Power Apps 方案即可取得 Power Apps 管理員 PowerShell Cmdlet 的系統管理存取權。 但是,這些系統管理員必須至少先登入一次 Power Platform 系統管理中心,才能使用 PowerShell Cmdlet。 若未完成此作業,Cmdlet 將會失敗,並發生授權錯誤。

  • 如果您需要搜尋其他使用者的資源,則必須有 Microsoft 365 全域管理員、Azure Active Directory 全域系統管理員、Power Platform 系統管理員或 Dynamics 365 系統管理員權限。 請注意,環境管理員只能存取他們有權存取的環境和環境資源。

  • 針對 Dataverse for Teams 環境,您必須是 Microsoft 365 全域管理員、Azure Active Directory 全域系統管理員或 Power Platform 系統管理員,才能管理您不是 Microsoft Teams 團隊負責人的環境。