2020/06/15

用 PowerShell 找出 Windows Task Schedule 裡超過時間的排程

``` Get-ScheduledTask | ? State -eq Running | Get-ScheduledTaskInfo | % { $lastRunTime = [datetime]::parse($_.LastRunTime) $lastRunTime $ts = New-TimeSpan -Start $lastRunTime -End (Get-Date) $ts.Minutes if ($ts.Minutes -gt 10) { Write-Host $_.TaskName Write-Host "Running over 10 minutes!!" } } ```

沒有留言: