Select your language

Power Automate Flow Inventory Script

Inventory Power Automate Flows with SharePoint, Connectors, and Owners

If you manage Microsoft Power Platform environments across your organization, getting a clear view of your Power Automate flows can be a challenge. Who owns them? Which connectors are in use? Are flows connected to SharePoint lists or document libraries?

This PowerShell script helps you generate a complete inventory of flows across all environments, including:

  • The environment ID
  • The Flow Name
  • The owner of each flow
  • The Type of item line :
    • Connector used by the flow
    • Resource depending on one of the connectors
  • The connectors used (like SharePoint, Outlook, etc.)
  • Referenced resource depending on the connector : SharePoint sites, lists, and files ID (when applies) - this will produce additional line(s) if data is available
  • The flow status (enabled/disabled)
  • The creation date of each flow

The result is exported into a CSV file with a timestamped filename for easy tracking and archiving.

id5 001

How the Script Works

1. Module Verification

The script first checks for required PowerShell modules:

  • Microsoft.PowerApps.Administration.PowerShell

  • Microsoft.Graph.Users

If they're missing, it installs them automatically.

2. Interactive Login

The user is prompted to log into:

  • Power Platform Admin Center (Add-PowerAppsAccount)

  • Microsoft Graph API (Connect-MgGraph with User.Read.All scope)

3. Flow Extraction

The script retrieves all flows using Get-AdminFlow and loops through them. For each flow:

  • It collects the environment name, creation date, and status

  • It tries to resolve the user's display name based on the used id from Microsoft Graph.
    Value is set to Unknown User if the user is not found.

  • It extracts the connectors in use

  • It looks for referenced SharePoint resources, keeping unique values only and filtering out placeholders like [DYNAMIC_VALUE]

4. Progress Feedback

During execution, the script displays a real-time percentage to track the progress of the export.

5. CSV Export

All results are exported to a CSV file named like FlowInventory_2025-04-15.csv in the current directory.


The Script

Below is the full PowerShell script you can use or adapt:

# Check and install required modules if missing
$requiredModules = @(
    "Microsoft.PowerApps.Administration.PowerShell",
    "Microsoft.Graph.Users"
)

foreach ($module in $requiredModules) {
    if (-not (Get-Module -ListAvailable -Name $module)) {
        Write-Host "📦 Installing required module: $module" -ForegroundColor Yellow
        Install-Module -Name $module -Scope CurrentUser -Force -AllowClobber
    }
}

Import-Module Microsoft.PowerApps.Administration.PowerShell
Import-Module Microsoft.Graph.Users

# Login
Write-Host "`n🔐 Connecting to Power Platform..." -ForegroundColor Cyan
Add-PowerAppsAccount

Write-Host "🔐 Connecting to Microsoft Graph..." -ForegroundColor Cyan
Connect-MgGraph -Scopes "User.Read.All"

$Results = @()
$Flows = Get-AdminFlow
$totalFlows = $Flows.Count
$flowIndex = 0

foreach ($Flow in $Flows) {
    $flowIndex++
    $progressPercent = [math]::Round(($flowIndex / $totalFlows) * 100)
    Write-Host "Processing flow $flowIndex / $totalFlows ($progressPercent%) - $($Flow.DisplayName)" -ForegroundColor DarkGray

    $EnvironmentId = $Flow.EnvironmentName
    $FlowName = $Flow.DisplayName
    $CreatedOn = $Flow.CreatedTime
    $Status = if ($Flow.Enabled -eq $true) { "Enabled" } else { "Disabled" }

    try {
        $FlowInfo = Get-AdminFlow -FlowName $Flow.FlowName -EnvironmentName $EnvironmentId
    } catch {
        Write-Host "⚠️ Failed to retrieve flow details: $FlowName" -ForegroundColor Red
        continue
    }

    try {
        $user = Get-MgUser -UserId $FlowInfo.CreatedBy.objectId -ErrorAction Stop
        $FlowOwner = $user.DisplayName
    } catch {
        $FlowOwner = "Unknown User"
    }

    $ConnectorDisplayNames = $FlowInfo.Internal.properties.connectionReferences.PSOBJECT.Properties.value.displayname
    foreach ($dspname in $ConnectorDisplayNames) {
        $Results += [pscustomobject]@{
            EnvironmentId = $EnvironmentId
            FlowName      = $FlowName
            Type          = "Connector"
            Owner         = $FlowOwner
            Scope         = "Connector"
            Details       = $dspname
            CreatedOn     = $CreatedOn
            Status        = $Status
        }
    }

    $ConnectorResourceList = $FlowInfo.Internal.properties.referencedResources.resource

    foreach ($resource in $ConnectorResourceList) {
        if ($resource.site) {
            $Results += [pscustomobject]@{
                EnvironmentId = $EnvironmentId
                FlowName      = $FlowName
                Type          = "Resource"
                Owner         = $FlowOwner
                Scope         = "site"
                Details       = $resource.site
                CreatedOn     = $CreatedOn
                Status        = $Status
            }
        }
        if ($resource.list) {
            $Results += [pscustomobject]@{
                EnvironmentId = $EnvironmentId
                FlowName      = $FlowName
                Type          = "Resource"
                Owner         = $FlowOwner
                Scope         = "list"
                Details       = $resource.list
                CreatedOn     = $CreatedOn
                Status        = $Status
            }
        }
        if ($resource.fileid) {
            $Results += [pscustomobject]@{
                EnvironmentId = $EnvironmentId
                FlowName      = $FlowName
                Type          = "Resource"
                Owner         = $FlowOwner
                Scope         = "id"
                Details       = $resource.fileid
                CreatedOn     = $CreatedOn
                Status        = $Status
            }
        }
    }
}

# Export with date-stamped filename
$DateStamp = Get-Date -Format "yyyy-MM-dd"
$ExportPath = ".\FlowInventory_$DateStamp.csv"
$Results | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8BOM -Delimiter ";"

Write-Host "`n✅ Export completed: $ExportPath" -ForegroundColor Green

Next Steps

You can now import this CSV into Excel or Power BI to:

  • Track unused or orphaned flows

  • Identify flows using deprecated connectors

  • Audit SharePoint dependencies

  • Group flows by owner or environment

For automation, this script can also be scheduled via Task Scheduler or integrated into a compliance workflow.


🙌 Hope You Found This Useful

We hope you enjoyed this article and that the script helps you gain better visibility into your Power Automate flows.

If you have any questions, feedback, or suggestions for improvements, feel free to leave a comment below — we’d love to hear from you!