PowerShell support for Power Automate isn’t native like Exchange or SharePoint. But you can still get things done using:
- Microsoft Power Platform CLI
- Microsoft Graph PowerShell SDK
- Invoke-RestMethod with raw Graph or Flow API endpoints
Connect-MgGraph -Scopes "https://graph.microsoft.com/.default"
$environmentId = "<ENVIRONMENT_ID>"
$flows = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/solutions/businessScenarios/$environmentId/workflows"
$flows.value | Select-Object name, id, createdDateTime, state
$ownerId = "<USER_OBJECT_ID>"
$flows = Get-FlowsByUser -OwnerId $ownerId # You’ll need to define this logic
foreach ($flow in $flows) {
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/beta/solutions/businessScenarios/$($flow.environmentId)/workflows/$($flow.id)/stop"
}
$flowId = "<FLOW_ID>"
$environmentId = "<ENVIRONMENT_ID>"
$response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/solutions/businessScenarios/$environmentId/workflows/$flowId/definition"
$response | Out-File "C:\scripts\FlowExport.json"
$userId = "<USER_OBJECT_ID>"
$uri = "https://graph.microsoft.com/beta/users/$userId/insights/shared"
$response = Invoke-MgGraphRequest -Method GET -Uri $uri
$response.value | Where-Object { $_.resourceReference.resourceType -eq "Microsoft.Flow/flows" }
Invoke-MgGraphRequest -Method DELETE -Uri "https://graph.microsoft.com/beta/solutions/businessScenarios/$environmentId/workflows/$flowId"