通过 PowerShell 删除所有running状态的flow

发布时间 2023-05-08 22:24:15作者: TheMiao

我们经常会出现流出现多个running并且run不完的情况下。 并且积攒过多会导致降速问题。

所以我们可以通过powershell来运行cancel这些running状态运行。

 

 

首先我们要安装NPM,并且运行

npm i -g @pnp/cli-microsoft365

 

 

安装成功之后,我们要登陆

m365 login

 

这里我们要从devicelogin登陆并且输入code。

 

下一步我们要确认environment和flow guid

$currentFlowRuns = m365 flow run list --environmentName <Guid of the environment> --flowName <GUID of the flow> --output json | ConvertFrom-Json

然后循环运行

foreach ($run in $currentFlowRuns) {
  if ($run.status -eq "Running") {

    # Cancel all the running flow runs
    m365 flow run cancel --environmentName <guid of environment> --flowName <guid of environment> --name $run.name --confirm
    Write-Output "Flow Run has been cancelled successfully"
  }
}