PowerShell – Get the list of all connectors used by each Power Apps application

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
# Required Modules (installed as admin)
#   Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
#   Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
#
$Delimiter = ","
# Get list of all Environments
$Environments = Get-PowerAppEnvironment | Select-Object -Property EnvironmentName, DisplayName 

write-host $Environments

# Loop through all Environments 
foreach ($Environment in $Environments)
{
    # List all Apps in each environments
    $AppNames = Get-PowerApp -EnvironmentName $Environment.EnvironmentName | Select-Object -Property AppName, DisplayName

    # Loop through each app to get connectors it is using
    foreach ($AppName in $AppNames) {
        $Connectors = Get-AdminPowerAppConnectionReferences -EnvironmentName $Environment.EnvironmentName -AppName $AppName.AppName | Select-Object -Property ConnectorName

        # Write outputs
        ForEach ($Connector in $Connectors.ConnectorName) {
            Write-Output ($Environment.DisplayName + $Delimiter + $AppName.DisplayName + $Delimiter + $Connector) 
        }
    }
}

# Outputs in format of 
# Environment, App Name, Connector Names
# Env 1,Booking App,shared_office365users
# Env 1,Booking App,shared_office365
# Env 2,Message App,shared_skypeforbiz