Skip to content

Instantly share code, notes, and snippets.

@LauraKokkarinen
Created May 18, 2024 07:31
Show Gist options
  • Save LauraKokkarinen/648f6fa092fd4d66cbec78ac29ad730a to your computer and use it in GitHub Desktop.
Save LauraKokkarinen/648f6fa092fd4d66cbec78ac29ad730a to your computer and use it in GitHub Desktop.
$tenantId = "your-tenant-guid-92ca-a9b3993e45aa"
$subscriptionId = "your-subscription-guid-8cc2-bf3751b1e868"
$resourceGroupName = "your-resource-group-name"
$logicAppName = "your-logic-app-name"
# The hour value should be given in UTC, which is probably different from the one you see on Azure Portal
$startTimeFrom = (Get-Date -Day 16 -Month 5 -Year 2024).Date.AddHours(7).AddMinutes(00).AddSeconds(00)
$startTimeTo = (Get-Date -Day 16 -Month 5 -Year 2024).Date.AddHours(8).AddMinutes(36).AddSeconds(10)
# If the script seems to hang, uncomment the -DeviceCode flag
Connect-AzAccount -TenantId $tenantId -Subscription $subscriptionId #-DeviceCode
# Without FollowNextPageLink, the command only returns the latest 30 runs
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -FollowNextPageLink |
Where-Object { (Get-Date $_.StartTime) -ge (Get-Date $startTimeFrom) `
-and (Get-Date $_.StartTime) -le (Get-Date $startTimeTo) `
-and $_.Status -eq "Running" }
$runs.StartTime.DateTime
Read-Host -Prompt "Press any key to cancel the above runs or CTRL+C to quit" | Out-Null
$runs | Stop-AzLogicAppRun -ResourceGroupName $resourceGroupName -Name $logicAppName -RunName {$_.Name} -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment