Power Automate: Get most frequently used actions

Introduction


PnP cmdlets are fantastic for managing your flows. Faster to code than CSOM, more options than classic SharePoint Online Management Shell.

Get Flow Properties


Using PnP you can retrieve properties of the flow. Remember to use -AsAdmin switch. Otherwise you will get only your own flows.

Connect-PnpOnline
$environment = Get-PnPPowerPlatformEnvironment
$FlowProps = Get-PnPFlow -Environment $environment -AsAdmin | select -expandProperty Properties

Get Actions of a Single Flow


Among the available properties, you find DefinitionSummary. It allows you to see triggers and actions of a flow

$FlowProps.DefinitionSummary

Get Most Common Action in All Flows

Using Group-Object and Sort-Object cmdlets you can get the most common actions used in all Flows. In the picture, the first empty position you see in the results refers to actions such as InitializeVariable, SetVariable, Foreach loops, If Condition, and other Control elements.

$FlowProps.DefinitionSummary.Actions | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending


 

Export to CSV

$FlowProps.DefinitionSummary.Actions | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending | Export-Csv -Path C:\users\Public\mostcommonactions.csv

Full Script

Connect-PnpOnline
$environment = Get-PnPPowerPlatformEnvironment
$FlowProps = Get-PnPFlow -Environment $environment -AsAdmin | select -expandProperty Properties
$FlowProps.DefinitionSummary.Actions | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending | Export-Csv -Path C:\users\Public\mostcommonactions.csv

Get Most Common Triggers

Using Group-Object and Sort-Object cmdlets you can also get the most common triggers used in all Flows. The empty positions are triggers of instant cloud flows.

$FlowProps.DefinitionSummary.Triggers | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending

Export to CSV

$FlowProps.DefinitionSummary.Triggers | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending | Export-csv -Path C:\Users\Public\triggies.csv

Full Script

Connect-PnpOnline
$environment = Get-PnPPowerPlatformEnvironment
$FlowProps = Get-PnPFlow -Environment $environment -AsAdmin | select -expandProperty Properties
$FlowProps.DefinitionSummary.Triggers | Group-Object swaggerOperationid | Sort-Object -Property Count -Descending | Export-Csv -Path C:\users\Public\mostcommonactions.csv

See Also



Power Automate scripts at GitHub

PnP cmdlets