Find and Stop Azure Automation Suspended Jobs

Nov 27, 2019

In this post, I have provided a PowerShell script to find jobs using the Update Management automation patching scripts, and stop suspended jobs.

CREATE USER [dbreader@lanet.co.uk] FROM EXTERNAL PROVIDER WITH DEFAULT_SCHEMA=[dbo]
GO
GRANT SELECT ON dbo.Customers TO "dbreader@yourdomain.co.uk" >


$SuspendedJobs = Get-AzAutomationJob -Status Suspended -ResourceGroupName $AutomationAccountRG -AutomationAccountName $AutomationAccountName | where {$job.RunbookName -match "Patch" }
$SuspendedJobs
Foreach($Job in $SuspendedJobs)
{
Stop-AzAutomationJob -Id $job.JobId -ResourceGroupName $AutomationAccountRG -AutomationAccountName $AutomationAccountName
}