Bulk Flow Toggle by Environment
Admin-triggered flow that enables or disables all flows matching a naming pattern in a specific environment, logging each action.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
FlowLibs - Bulk Flow Toggle by Environment is an admin-triggered, instant cloud flow that lets a Power Platform administrator turn a whole batch of Power Automate cloud flows On or Off in a single click — by matching their display names against a substring pattern within a target environment. Every toggle attempt (success or failure) is logged to a SharePoint audit list, and a styled HTML summary is emailed to a designated recipient when the run completes.
It is built as a reference implementation on the Power Automate Management connector, demonstrating the canonical pattern for admin-scope flow management automation.
Use Case
Common scenarios where this is useful include tenant cutover / freeze windows (disable every flow in a production solution before a planned database migration, then re-enable them in one click after the migration completes), cost / quota controls (disable all Hackathon - flows on the last Friday of every month so they don't burn API actions over the weekend), lifecycle hygiene (disable all Sandbox - flows in a dev environment after a sprint ends; re-enable selectively when devs return), and incident response (when a downstream system goes down, quickly disable all flows that target it without hunting through the My Flows list one by one).
The flow ships Off by design. Activate it in your tenant by authorizing the three connection references (Power Automate Management, SharePoint, Office 365 Outlook), setting flowlibs_TargetEnvironmentName to your environment ID, setting flowlibs_FlowToggleNamePattern to your naming convention prefix, confirming flowlibs_BulkToggleLogList matches the SharePoint list title in your site, then turning the flow On.
The flow is ideal for teams that:
- Tenant cutover / freeze windows — disable every flow in a production solution before a planned database migration, then re-enable them in one click
- Cost / quota controls — disable all Hackathon - flows on weekends so they don't burn API actions
- Lifecycle hygiene — disable all Sandbox - flows in a dev environment after a sprint ends
- Incident response — when a downstream system goes down, quickly disable all flows that target it
Flow Architecture
Manually trigger a flow
Request (Button)Single text input `Action` — the user types `Enable` or `Disable`.
Init varTargetEnvironment
Initialize variableReads `flowlibs_TargetEnvironmentName` env var into `varTargetEnvironment`.
Init varNamePattern
Initialize variableReads `flowlibs_FlowToggleNamePattern` env var into `varNamePattern`.
Init varLogListName
Initialize variableReads `flowlibs_BulkToggleLogList` env var into `varLogListName`.
Init varSharePointSiteUrl
Initialize variableReads `flowlibs_SharePointSiteURL` env var into `varSharePointSiteUrl`.
Init varNotificationEmail
Initialize variableReads `flowlibs_NotificationEmailAddress` env var into `varNotificationEmail`.
Init varAction
Initialize variableNormalizes the trigger input to upper case using `@toUpper(triggerBody()?['text'])` so the Switch can match `ENABLE` / `DISABLE` regardless of how the admin typed it.
Init varSuccessCount
Initialize variableInteger counter, starts at 0.
Init varFailureCount
Initialize variableInteger counter, starts at 0.
Init varSkippedCount
Initialize variableInteger counter, starts at 0.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_TargetEnvironmentName | String | <your-tenant-id> | Power Platform environment ID to operate against. Replace with your target environment's GUID (the default- prefixed ID found in the environment URL). |
| flowlibs_FlowToggleNamePattern | String | FlowLibs - | Substring matched against each flow's display name (case-insensitive). Set to an empty string to match every flow in the environment (use with caution). |
| flowlibs_BulkToggleLogList | String | FlowLibs - Bulk Toggle Audit Log | SharePoint list title used to log toggle actions. |
| flowlibs_SharePointSiteURL | String | https://your-tenant.sharepoint.com | SharePoint root URL where the audit list lives. |
| flowlibs_NotificationEmailAddress | String | you@yourcompany.com | Recipient for the run summary email. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Power Automate Management | shared_flowmanagement | ListFlowsInEnvironment (admin-scope retrieval of cloud flows in the target environment) StartFlow (enables a flow by GUID) StopFlow (disables a flow by GUID) |
| SharePoint | shared_sharepointonline | PostItem (writes one audit row per toggled flow) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (delivers the run summary email) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Change the matching scope
- Set flowlibs_FlowToggleNamePattern to any substring; the filter is case-insensitive (@contains(toLower(displayName), toLower(pattern))). Set it to '' (empty string) to match every flow, but be careful — the loop will run against all flows in the env.
- Switch environments
- Set flowlibs_TargetEnvironmentName to a different environment ID. The same identity must have admin rights in that environment for ListFlowsInEnvironment (admin scope) to return results.
- Change the audit destination
- Point flowlibs_SharePointSiteURL and flowlibs_BulkToggleLogList at any list with the same column shape; the SharePoint connector will write to whatever list is named.
- Change the recipient
- flowlibs_NotificationEmailAddress is bound only into the Send Summary Email action; updating it requires no flow edit.
- Add an Approval gate
- Wire Start and wait for an approval (shared_approvals / StartAndWaitForAnApproval) before the For Each loop and read body('...')?['outcome'] to gate the toggle. Useful when production toggles need a second pair of eyes.
- Per-owner filtering
- Extend Filter Matching Flows to also match item()?['properties']?['creator']?['userId'] against a list of allowed UPNs / object IDs, so you only toggle flows owned by a specific team.
- Switch from substring match to regex / exact match
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Normalize trigger input
Used in `Init varAction` so the Switch matches `ENABLE` / `DISABLE` regardless of casing.
EXPR.02Case-insensitive display name match
`Filter Matching Flows` where clause — null-safe substring match against the flow's properties.displayName.
EXPR.03Flow GUID for Start/Stop
The `name` field on each flow object IS the flow GUID — passed as the path parameter to StartFlow / StopFlow.
EXPR.04Captured error message with fallback
`Log Toggle Failure` ErrorMessage column — pulls the first error from the failed Scope, falls back to a generic message.
EXPR.05Summary email subject
Concatenates the action label, success count, and total matching count into a one-line summary.
EXPR.06Total flows in environment
Reports the full count of flows in the environment in the summary email so the admin can validate the matching ratio.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.