Search flows for connections
Summary
Search all flows as, an administrator, for a specific search string and report results. This sample allows you to get a report of all flows that are connected to a specific site or list. The
$searchString
can be any value but results are the best when using a GUID or site collection URL.
Write-Output "Retrieving all environments"
$environments = m365 flow environment list -o json | ConvertFrom-Json
$searchString = "15f5b014-9508-4941-b564-b4ab1b863a7a" #listGuid
$path = "exportedflow.json";
ForEach ($env in $environments) {
Write-Output "Processing $($env.displayName)..."
$flows = m365 flow list --environment $env.name --asAdmin -o json | ConvertFrom-Json
ForEach ($flow in $flows) {
m365 flow export --id $flow.name --environment $env.name --format json --path $path
$flowData = Get-Content -Path $path
if ($flowData.Contains($searchString)) {
Write-Output $($flow.displayName + "contains your search string" + $searchString)
Write-Output $flow.id
}
Remove-Item $path -Confirm:$false
}
}
Check out the CLI for Microsoft 365 to learn more at: https://aka.ms/cli-m365
Source Credit
Sample first appeared on Search flows for connections | CLI for Microsoft 365
Contributors
Author(s) |
---|
Albert-Jan Schot |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.