Skip to content

cosmicthoughts/Powershell-for-Power-Automate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Powershell-for-Power-Automate

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

List All Flows in an Environment

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

Disable All Flows by a Specific User

$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"
}

Export a Flow Definition

$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"

Find Flows Shared with a User

$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" }

Delete a Flow

Invoke-MgGraphRequest -Method DELETE -Uri "https://graph.microsoft.com/beta/solutions/businessScenarios/$environmentId/workflows/$flowId"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published