PowerShell support for PowerApps (preview)

With the preview launch of the PowerShell cmdlets for app creators and administrators, you can automate many of the monitoring and management tasks that are only possible manually today in PowerApps or the PowerApps Admin center.

Installation

To run the PowerShell cmdlets for app creators, do the following:

  1. Download the PowerShell scripts file.

  2. Unzip the file into a folder.

  3. Open a PowerShell command window (as administrator) in that same folder.

  4. Run the following one-time PowerShell command (this presumes you've never run PowerShell commands on the current machine):

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
    
  5. Import the necessary modules using the following commands:

    Import-Module .\Microsoft.PowerApps.Administration.PowerShell.psm1 -Force
    Import-Module .\Microsoft.PowerApps.PowerShell.psm1 -Force
    
  6. There is a known issue today that may also require you to manually unblock the PowerShell files using the following command:

    dir . | Unblock-File
    
  7. Before accessing any of the commands, provide your credentials using the following command. These credentials are refreshed for up to ~8 hours before you're required to sign in again to continue using the cmdlets.

    # This call will open a prompt to collect the credentials (AAD account & password) that will be used by the commands
    Add-PowerAppsAccount
    
    # Here is how you can pass in credentials (avoiding opening a prompt)
    $pass = ConvertTo-SecureString "password" -AsPlainText -Force
    Add-PowerAppsAccount -Username foo@bar.com -Password $pass
    

PowerApps cmdlets for app creators (preview)

Prerequisite

Users with a valid PowerApps license can perform the operations in these cmdlets, but they will only have access to the resources (for example, apps, flows, etc.) that have been created or shared with them.

Cmdlet list

Note

We have updated some of the cmdlets function names in the latest release in order to add appropriate prefixes to prevent collisions. See the table below for an overview of what has changed.

Purpose Cmdlet
Read environments Get-PowerAppEnvironment (previously Get-PowerAppsEnvironment)
Get-FlowEnvironment
Read, update, and delete a canvas app Get-PowerApp (previously Get-App)
Remove-PowerApp (previously Remove-App)
Publish-PowerApp (previously Publish-App)
Set-AppDisplayName (previously Set-PowerAppDisplayName)
Get-PowerAppVersion (previously Get-AppVersion)
Restore-PowerAppVersion (previously Restore-AppVersion)
Read, update, and delete canvas app permissions Get-PowerAppRoleAssignment (previously Get-AppRoleAssignment)
Set-PowerAppRoleAssignment (previously Set-AppRoleAssignment)
Remove-PowerAppRoleAssignment (previously Remove-AppRoleAssignment)
Read, update, and delete a flow Get-Flow
Get-FlowRun
Enable-Flow
Disable-Flow
Remove-Flow
Read, update, and delete flow permissions Get-FlowOwnerRole
Set-FlowOwnerRole
Remove-FlowOwnerRole
Read and respond to flow approvals Get-FlowApprovalRequest
Get-FlowApproval
RespondTo-FlowApprovalRequest
Read and delete connections Get-PowerAppConnection (previously Get-Connection)
Remove-PowerAppConnection (previously Remove-Connection)
Read, update, and delete connection permissions Get-PowerAppConnectionRoleAssignment (previously Get-ConnectionRoleAssignment)
Set-PowerAppConnectionRoleAssignment (previously Set-ConnectionRoleAssignment)
Remove-PowerAppConnectionRoleAssignment (previously Remove-ConnectionRoleAssignment)
Read and delete connectors Get-PowerAppConnector (previously Get-Connector)
Remove-PowerAppConnector (previously Remove-Connector)
Read, update, and delete custom connector permissions Get-PowerAppConnectorRoleAssignment (previously Get-ConnectorRoleAssignment)
Set-PowerAppConnectorRoleAssignment (previously Set-ConnectorRoleAssignment)
Remove-PowerAppConnectorRoleAssignment (previously Remove-ConnectorRoleAssignment)

Note

Use the following commands to understand syntax and view samples for each of the cmdlets:

Get-Help Get-PowerAppEnvironment
Get-Help Get-PowerAppEnvironment -Examples
Get-Help Get-PowerAppEnvironment -Detailed

PowerApps cmdlets for administrators (preview)

Prerequisite

To perform the administration operations in the admin cmdlets, you'll need the following:

Cmdlet list

Note

We have updated some of the cmdlets function names in the latest release in order to add appropriate prefixes to prevent collisions. See the table below for an overview of what has changed.

Purpose Cmdlets
Read, update, and delete environments & Common Data Service for Apps databases New-AdminPowerAppEnvironment *New*
Set-AdminPowerAppEnvironmentDisplayName *New*
Get-AdminPowerAppEnvironment (previously Get-AdminEnvironment)
Remove-AdminPowerAppEnvironment (previously Remove-AdminEnvironment)
New-AdminPowerAppCdsDatabase *New*
Get-AdminPowerAppCdsDatabaseLanguages *New*
Get-AdminPowerAppCdsDatabaseCurrencies *New*
Get-AdminPowerAppEnvironmentLocations *New*
Read, update, and delete environment permissions

These cmdlets only work today for environments that do not have a Common Data Service (CDS) for Apps database.
Get-AdminPowerAppEnvironmentRoleAssignment (previously Get-AdminEnvironmentRoleAssignment)
Set-AdminPowerAppEnvironmentRoleAssignment (previously Set-AdminEnvironmentRoleAssignment)
Remove-AdminPowerAppEnvironmentRoleAssignment (previously Remove-AdminEnvironmentRoleAssignment)
Read, update, and remove canvas apps Get-AdminPowerApp (previously Get-AdminApp)
Remove-AdminPowerApp (previously Remove-AdminApp)
Get-AdminPowerAppConnectionReferences *New*
Set-AdminPowerAppAsFeatured *New*
Clear-AdminPowerAppAsFeatured *New*
Set-AdminPowerAppAsHero *New*
Clear-AdminPowerAppAsHero *New*
Set-AdminPowerAppApisToBypassConsent *New*
Clear-AdminPowerAppApisToBypassConsent *New*
Read, update, and delete canvas app permissions Get-AdminPowerAppRoleAssignment (previously Get-AdminAppRoleAssignment)
Remove-AdminPowerAppRoleAssignment (previously Remove-AdminAppRoleAssignment)
Set-AdminPowerAppRoleAssignment (previously Set-AdminAppRoleAssignment)
Set-AdminPowerAppOwner (previously Set-AdminAppOwner)
Read, update, and delete flows Get-AdminFlow
Enable-AdminFlow
Disable-AdminFlow
Remove-AdminFlow
Remove-AdminFlowApprovals *New*
Read, update, and delete flow permissions Get-AdminFlowOwnerRole
Set-AdminFlowOwnerRole
Remove-AdminFlowOwnerRole
Read and delete connections Get-AdminPowerAppConnection (previously Get-AdminConnection)
Remove-AdminPowerAppConnection (previously Remove-AdminConnection)
Read, update, and delete connection permissions Get-AdminPowerAppConnectionRoleAssignment (previously Get-AdminConnectionRoleAssignment)
Set-AdminPowerAppEnvironmentConnectionRoleAssignment (previously Set-AdminConnectionRoleAssignment)
Remove-AdminPowerAppConnectionRoleAssignment (previously Remove-AdminConnectionRoleAssignment)
Read and delete custom connectors Get-AdminPowerAppConnector (previously Get-AdminConnector)
Remove-AdminPowerAppConnector (previously Remove-AdminConnector)
Read, update, and delete custom connector permissions Get-AdminPowerAppConnectorRoleAssignment (previously Get-AdminConnectorRoleAssignment)
Set-AdminPowerAppConnectorRoleAssignment (previously Set-AdminConnectorRoleAssignment)
Remove-AdminPowerAppConnectorRoleAssignment (previously Remove-AdminConnectorRoleAssignment)
Read a user's PowerApps user settings, user-app settings, and notifications Get-AdminPowerAppsUserDetails
Read & delete a user's Microsoft Flow settings, which are not visible to user, but that support flow execution Get-AdminFlowUserDetails
Remove-AdminFlowUserDetails
Create, read, update & delete data loss prevention policies for your organization Get-AdminDlpPolicy (previously Get-AdminApiPolicy)
Add-AdminDlpPolicy (previously Add-AdminApiPolicy)
Remove-AdminDlpPolicy (previously Remove-AdminApiPolicy)
Set-AdminDlpPolicy (previously Set-AdminApiPolicy)
Add-ConnectorToBusinessDataGroup
Remove-ConnectorFromBusinessDataGroup

Note

Use the following commands to understand syntax and view sample for each of the cmdlets:

Get-Help Get-AdminPowerAppEnvironment
Get-Help Get-AdminPowerAppEnvironment -Examples
Get-Help Get-AdminPowerAppEnvironment -Detailed

Version History

Version Date Updates
1.0 04/23/2018
  1. Initial launch of the PowerApps cmdlets for app creators (preview) including management cmdlets for Environments, Apps, Flows, Flow approvals, Connections, and Custom Connectors
  2. Initial launch of the PowerApps cmdlets for administrators (preview) including administrative cmdlets for Environments, Apps, and Flows
2.0 05/24/2018
  1. Minor bug fixes in both the cmdlets for app creators and administrators
  2. Added the following new administrative cmdlets:
    Get-AdminConnection
    Remove-AdminConnection
    Get-AdminConnectionRoleAssignment
    Set-AdminConnectionRoleAssignment
    Remove-AdminConnectionRoleAssignment
    Get-AdminConnector
    Remove-AdminConnector
    Set-AdminConnectorRoleAssignment
    Get-AdminConnectorRoleAssignment
    Remove-AdminConnectorRoleAssignment
    Get-AdminPowerAppsUserDetails
    Get-AdminFlowUserDetails
    Remove-AdminFlowUserDetails
    Get-AdminApiPolicy
    Add-AdminApiPolicy
    Remove-AdminApiPolicy
    Set-AdminApiPolicy
    Add-ConnectorToBusinessDataGroup
    Remove-ConnectorFromBusinessDataGroup
3.0 07/30/2018
  1. Added the ability to pass-in credentials to the Add-PowerAppsAccount (to enable recurring scripting)
  2. Minor bug fixes in both the cmdlets for app creators and administrators
  3. Added the "PowerApp" or "Flow" prefix to each cmdlet for app creators
  4. Added the "AdminPowerApp" or "AdminFlow" prefix to each cmdlet for administrators
  5. Added the following new administrative cmdlets:
    New-AdminPowerAppEnvironment
    Set-AdminPowerAppEnvironmentDisplayName
    New-AdminPowerAppCdsDatabase
    Get-AdminPowerAppCdsDatabaseLanguages
    Get-AdminPowerAppCdsDatabaseCurrencies
    Get-AdminPowerAppEnvironmentLocations
    Get-AdminPowerAppConnectionReferences
    Set-AdminPowerAppAsFeatured
    Clear-AdminPowerAppAsFeatured
    Set-AdminPowerAppAsHero
    Clear-AdminPowerAppAsHero
    Set-AdminPowerAppApisToBypassConsent
    Clear-AdminPowerAppApisToBypassConsent
    Remove-AdminFlowApprovals
4.0 08/15/2018 Added an optional parameter to the New-AdminPowerAppCdsDatabase to make the function synchronous, by default (i.e. it will not return until the database is successfully provisioned)
5.0 08/24/2018 Fixed an issue where the Flow admin cdmlets where not returning data for some using based on their security settings

Questions?

If you have any comments, suggestions, or questions, post them on the Administering PowerApps community board.