web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Fetch each Flow, servi...
Power Automate
Answered

Fetch each Flow, service accounts and connectors for an Environment 2

(0) ShareShare
ReportReport
Posted on by 169
Is there a way to get the name of each Flow which is mine or has been shared with me?  I also want to know which connectors its using and which account it uses to use the connectors.
 
 
The problem is that this script uses a command Get-Flow which I don't think is valid in Powershell 7.  I use Get-AdminFlow instead.  Everything is still coming out Unable to resolve as per the Catch statement below.  Also, when I run the script there is no command Get-AdminFlow -SharedWithMe ie SharedWithMe is not a parameter for this command.
How can I fix this?
 
I'm open to using a Flow rather than Powershell.
 
$ownedFlows  = Get-Flow
$sharedFlows = Get-Flow -SharedWithMe
$allFlows = @($ownedFlows) + @($sharedFlows) |
            Sort-Object FlowName -Unique
Write-Host "Total Unique Flows Found: $($allFlows.Count)" -ForegroundColor Cyan
# -----------------------------------------------
# STEP 7: Build Report
# -----------------------------------------------
$report = @()
foreach ($flow in $allFlows) {
    Write-Host "Processing: $($flow.DisplayName)" -ForegroundColor Yellow
    # Get full flow details
    $flowDetail = Get-Flow `
        -FlowName $flow.FlowName `
        -EnvironmentName $flow.EnvironmentName
    # --- Ownership Type ---
    $isOwned       = ($ownedFlows.FlowName -contains $flow.FlowName)
    $ownershipType = if ($isOwned) { "Owned" } else { "Shared With Me" }
    # --- Flow Owner UPN from Azure AD ---
    $ownerUPN         = ""
    $ownerDisplayName = ""
    try {
        $createdById = $flowDetail.Internal.properties.creator.objectId
        if ($createdById) {
            $aadUser          = Get-AzureADUser -ObjectId $createdById
            $ownerUPN         = $aadUser.UserPrincipalName
            $ownerDisplayName = $aadUser.DisplayName
        }
    } catch {
        $ownerUPN         = "Unable to resolve"
        $ownerDisplayName = "Unable to resolve"
    }
 
Categories:
I have the same question (0)
  • Verified answer
    Haque Profile Picture
    3,653 on at
    Hi @AH-02011058-0
     
    Can you please run this diagnostic on any flow to see exactly what creator info is available? Please past me the result here. 
     
    $flow = Get-AdminFlow | Select-Object -First 1
    $detail = Get-AdminFlow -FlowName $flow.FlowName -EnvironmentName $flow.EnvironmentName
    $detail.Internal.properties | ConvertTo-Json -Depth 5 | Select-String "creator|createdBy"
     
  • AH-02011058-0 Profile Picture
    169 on at
    Thanks for the quick reply @Haque I got this message "WARNING: Resulting JSON is truncated as serialization has exceeded the set depth of 5." 
    The output has over 1700 rows with some GUIds and internal URLs that probably should not be made public.
     
    At the beginning
     
    {
      "apiId": "/providers/Microsoft.PowerApps/apis/shared_logicflows",
      "displayName": "qqq",
      "userType": "Owner",
      "definition": {
        "$schema":
    "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/qqq/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
          "$connections": {
            "defaultValue": {},
            "type": "Object"
          },
          "$authentication": {
            "defaultValue": {},
            "type": "SecureObject"
          },
          "EPMO_env_EPM_Site (corpapps_EPMO_env_EPM_Site)": {
            "defaultValue": "https://qqq.sharepoint.com/teams/X-OrgPortfolioGroup-Test",
            "type": "String",
            "metadata": {
              "schemaName": "corpapps_EPMO_env_EPM_Site",
              "description": "The site location for the EPMPortfolio list"
            }
          },
    ....
    Near the end
     
        "tenantId": "www",
        "objectId": "www",
        "userId": "www",
        "userType": "ActiveDirectory"
      },...
      "provisioningMethod": "FromDefinition",
      "flowFailureAlertSubscribed": true,
      "workflowEntityId": "www",
      "workflowUniqueId": "www",
      "referencedResources": [
        {
          "service": "sharepoint",
          "resource": {
            "site": "https://www.sharepoint.com/teams/X-OrgPortfolioGroup-Test",
            "list": "www"
          },
          "referencers": [
            {
              "referenceSourceType": "Triggers",
              "operationId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline/apiOperations/GetOnUpdatedItems"
            }
          ]
        },
     
  • AH-02011058-0 Profile Picture
    169 on at
    Hi @Haque,  I was able to use the diagnostic to find the solution.  The problem was that $createdById was not using the correct properties of $flow.
    This works for me.
     
    foreach ($flow in $allFlows) {
        #Write-Host "Processing: $($flow.DisplayName) Created by: $($flow.CreatedBy) Env: $ ($flow.EnvironmentName)" -ForegroundColor Yellow
        $ownerUPN         = ""
        $ownerDisplayName = ""
        try {
            
            $createdById = $flow.CreatedBy.objectId 
            
            if ($createdById) {
                $aadUser          = Get-AzADUser -ObjectId $createdById
                $ownerUPN         = $aadUser.UserPrincipalName
                $ownerDisplayName = $aadUser.DisplayName
            }
        } catch {
            $ownerUPN         = "Unable to resolve"
            $ownerDisplayName = "Unable to resolve"
        }
        # -

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard