I have a OneNote file that is full of blog posts that seemed like a great idea at the time, but never saw the light of day for various reasons. Maybe I couldn’t research it as much as I wanted, maybe I couldn’t make it as thorough as I wanted, maybe I just got distracted by something shiny. This blog post is one of them. I was never confident enough to post this one, but given all the Workflow excitement, and a couple of customer requests I decided to dig in and get serious about it. So here it is, two years after I first took the notes for it.
As an administrator, I find myself frustrated a lot by the lack, or at least lack of understanding on how to manage Flows and Power Apps. They never quite behave exactly like I want them to. One of the things that keeps coming up is being able to get a list of all of the Flows in a Tenant. This could be for licensing questions, migrating questions, or just plain curiosity. Whatever it is, it’s never as easy as I want it to be. Being the fanboy of PowerShell that I am, that’s where I looked. Without boring you with a lot of story part, I’ll show you the PowerShell I settled on.
Get-AdminFlow | ForEach-Object { $user = Get-UsersOrGroupsFromGraph -ObjectId $_.CreatedBy.userId;[PSCustomObject]@{ FlowName = $_.DisplayName; OwnerName = $user.DisplayName ; OwnerEmail = $user.UserPrincipalName ; }; }
Let’s break that down a bit. You’ll need to install the PowerApps and Flow for Admins module. Install the PowerApps and Flow for Makers module while you’re at it. If you don’t run Add-PowerAppsAccount and add your Tenant Admin account you’ll get prompted for authentication the first time you run Get-AdminFlow.
Get-AdminFlow lists all of the Flows in a tenant, but not in the most user friendly way:
So I cleaned it up a bit. Using ForEach-Object I walk through each Flow. I use Get-UsersOrGroupsFromGraph to get the Owner object. Then I create a PSCustomObject and populate it with the Flow’s DisplayName and the user’s DisplayName and UserPrincipalName properties. It looks like this:
Making it an object is a little extra work as opposed to just spewing it onto the screen with Write-Host. But it’s worth the extra effort because I can send it down the pipeline and do more with it. For instance, I can easily pipe it out to a CSV file by appending | Export-Csv -Path .\Flows.csv –NoTypeInformation to the end.
That seems a bit anticlimactic at first, but open up that CSV file and prepare to be amazed.
If you want different information about each Flow, run Get-AdminFlow | Get-Member and see what other properties are exposed to you.
Let me know if this helps and what else you’d like help with.
tk
ShortURL: https://www.toddklindt.com/POSHFindAllFlows
Edit 7/15/2020 – Changed the PowerShell to be more efficient, but now it doesn’t match the screenshots.