Automation of tasks with PowerShell

The PowerShell cmdlets enable admins to complete admin portal task using script commands. With PowerShell you can sequentially execute multiple commands at once or pipe output commands to automate common tasks.

Using PowerShell cmdlets and management connectors, admins can build flows and apps that help implement governance policies. You can use these example PowerShell cmdlets:

PowerShell cmdlet library Common tasks
Power Apps cmdlets
PowerShell support for Power Apps
Designed for app makers and administrators to automate tasks with environments and associated apps, flows, and connectors.
Microsoft 365 cmdlets
Get started with PowerShell for Microsoft 365
Use for Microsoft 365 related tasks to automate user-related actions and tasks. For example, the assignment of licenses.
Dynamics 365 cmdlets
Overview of Dynamics 365 Customer Engagement (on-premises) PowerShell
Use for environments with Microsoft Dataverse databases. Modules include support for the Dataverse online admin API, and automating solution deployment to the environments.
Microsoft Azure cmdlets
Azure PowerShell documentation
Use for including any Azure components in your overall solution. You can use for scripting setup of the on-prem application gateway.

You can use a combination of all the above cmdlets to build PowerShell scripts to do bulk operations on users, environments, or their resources.

Tip

Examples can also be found when installing and testing the Center of Excellence Starter Kit or using the Admin-in-a-Day hands-on labs that can be found on GitHub (Admin in a day).

Common PowerShell tasks

Displaying a list of environments

Get-AdminPowerAppEnvironment

Tasks give you key information, such as the Display Name and GUID of the environment. This task is often what is needed for follow-on operations.

Adding parameters, such as -Default, allows admins to generically find the default environment in the tenant.

Get-AdminPowerAppEnvironment -Default

Use the GUID to return a non-display name for the environment. Then you can drill into details of that specific environment. For example:

Get-AdminPowerAppEnvironment -Environment 'EnvironmentName'.

This returns the following:

User PowerShell to get environment details.

This example returns a list of connections in an environment, including all the connections in a tenant's default environment.

Get-AdminPowerAppEnvironment -Default | Get-AdminPowerAppConnection

This example pipes output from one cmdlet to another. It presents a list of number apps in each tenant environment.

    Get-AdminPowerApp | select -ExpandProperty EnvironmentName | Group | %{ New-Object -TypeName PSObject -Property @{ DisplayName = (Get-AdminPowerAppEnvironment -EnvironmentName $_.Name | select -ExpandProperty displayName); Count = $_.Count } }

That would produce the following detailed information:

User PowerShell to get environment app number details.