PowerPlatform : PowerApps – PowerShell script to list all PowerApps and respective connections used from the M365 tenant

Hi All,
Greetings for the day 🙂 LIFE IS BEAUTIFUL 🙂
Today something different related to Power Apps.
Background: My management has asked to list all PowerApps / PowerAutomates where SharePoint connection is used in our M365 tenant. This is something new for me so reasearch and then found an option of PowerShell script for listing PowerApps and respective connection details. But for PowerAutomate there is bit different approach which we will discuss in next article
Details / Steps:
- PowerShell CMDLETS for PowerApps are available in PowerShell gallery with two seperate modules:
- Administrator
- Maker
- We will use PowerShell PowerApps Administrator module
- If the Power Apps PowerShell Administrator module is not installed then we will install it using Install-Module CMDLET – https://www.powershellgallery.com/packages/Microsoft.PowerApps.Administration.PowerShell/2.0.131
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
- Once PowerShell module for PowerApps Administration installed successfully we are ready for our actual PowerShell – Getting all PowerApps and respective connection details
- We will execute CMDLET – Get-AdminPowerApp – https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerApps.Administration.PowerShell/get-adminpowerapp?view=pa-ps-latest
- This CMDLET returns details about all apps in the tenant which current user have access
$powerApp = Get-AdminPowerApp

- We will loop through each and every app
- We will use connectionReferences property of app – Internal.properties.connectionReferences – This property returns list of all connections used for app
$powerApp.Internal.properties.connectionReferences

- We will loop through each connection for app returned by connectionReferences property we will get the connection object
- From connection object we will fetch the connection id using Get-Member CMDLET as
$connectionId in ($connection | Get-Member -MemberType NoteProperty).Name

- Once we have connection id for every connection reference of App we will get the connection details
- We will prepare a row for every connection to add in CSV file
- We will export the CSV file using Export-Csv CMDLET
# output to file
$powerAppListings | Export-Csv -Path $Path
Complete PowerShell script:
<#
Preparing a .csv file having list of PowerApps and respective connections used from the tenant
#>
param(
[string]$Path = 'c:\powerApps_ConnectionDetails.csv'
)
#fetch the list of all PowerApps from the tenant.
#when the below CMDLET will execute it will ask for credentials for the tenant
$powerApps = Get-AdminPowerApp
$powerAppListings = @()
# loop through each app
foreach ($powerApp in $powerApps)
{
# loop through each connection reference for the respective APP
foreach($connectionReference in $powerApp.Internal.properties.connectionReferences)
{
#loop through each connection from the connection reference
foreach($connection in $connectionReference)
{
foreach ($connectionId in ($connection | Get-Member -MemberType NoteProperty).Name)
{
#get the connection details
$connectionDetails = $($connection.$connectionId)
#preparing row
$csvRow = @{
AppDisplayName = $powerApp.displayName
AppName = $powerApp.appName
EnvironmentName = $powerApp.environmentName
ConnectorDisplayName = $connectionDetails.displayName
ConnectionId = $connectionDetails.id
ConnectionName = $connectionDetails.connectionName
CreatedByEmail = $powerApp.owner.email
IsPremiumConnector = $connectionDetails.apiTier -eq 'Premium'
}
$powerAppListings+= $(new-object psobject -Property $csvRow)
}
}
}
}
# output to file
$powerAppListings | Export-Csv -Path $Path
- Output of the CSV file will lokk like as

Knowledge Junction has various PowerShell cmdlet in its Kitty, please have a look – https://knowledge-junction.in/category/technology-articles/powershell-cmdlets/
Knowledge Junction has good series of articles on Power Platform, please have a look once for more details – https://knowledge-junction.in/?s=power+platform
Reference:
Thanks for reading 🙂 If its worth at least reading once, kindly please like and share 🙂 SHARE ING IS CARING 🙂
Hi, thanks for you sharing! it is really useful to me! May I ask how can I list all users of the connectors?
Thanks, I’ll check once and update again.
Hi Again,
Bit confused with your requirement. Could you please share more details.
Is it so that you need – how many users have created specific connection ?
Hi Prasham,
This is an extremely helpful script! Thank you for sharing it!
Can you tell me how I can get the CSV file headers in a particular order? If you look at the Array variable $csvRow the order of the members of the array do not match the order of the CSV file.
For Example:
– your array has “AppDisplayName”, “AppName” then EnvironmentName…
– You CSV report headers are in a different order and start with “AppDisplayName”, “IsPremiumConnector” then “ConnectionId”.. which is a different order the how they were added to the array.
Why is it in a different order? Is it possible to get the column headers is specific order?