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

PowerShell script to fetch all PowerApps and respective connection details in M365 tenant
PowerShell script to fetch all PowerApps and respective connection details in 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:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell

PowerShell - PowerPlatform - Installing PowerApps Admin PowerShell Module
Fig : PowerShell – PowerPlatform – Installing PowerApps Admin PowerShell Module
PowerShell - PowerPlatform - Installing PowerApps Admin PowerShell Module
Fig : PowerShell – PowerPlatform – Installing PowerApps Admin PowerShell Module
 $powerApp = Get-AdminPowerApp 

Fig : Output of Get-AdminPowerApp cmdlet – Returns list of all PowerApps which current user has access
  • 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

Fig : Output of – $powerApp.Internal.properties.connectionReferences – returns list of connection references of App
  • 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

Fig : PowerApp connection detailes fetched
  • 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
Fig : CSV file having list of all PowerApps in tenant with respective connection details

Knowledge Junction has various PowerShell cmdlet in its Kitty, please have a look – https://knowledge-junction.com/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.com/?s=power+platform

Reference:

Thanks for reading πŸ™‚ If its worth at least reading once, kindly please like and share πŸ™‚ SHARE ING IS CARING πŸ™‚

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

1 Response

  1. August 27, 2021

    […] PowerPlatform : PowerApps – PowerShell script to list all PowerApps and respective connections use… […]

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: