PowerShell script exchange
Post Reply
rm4g00
Enthusiast
Posts: 39
Liked: never
Joined: Aug 02, 2016 11:58 am
Full Name: RM4G00
Contact:

Failed Job status - automatic retry ?

Post by rm4g00 »

Hello all,

Does anyone have a sample of a powershell code to basically scan for eqstatus failed then if failed start job again ?


Thanks

RM4G00
tsightler
VP, Product Management
Posts: 6009
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Failed Job status - automatic retry ?

Post by tsightler »

The post below has some code I put together that basically does this by looking for failed jobs and then retries. It should give you an idea of ways to do what you are asking.

powershell-f26/powershell-success-vm-ba ... ml#p205116
rm4g00
Enthusiast
Posts: 39
Liked: never
Joined: Aug 02, 2016 11:58 am
Full Name: RM4G00
Contact:

Re: Failed Job status - automatic retry ?

Post by rm4g00 »

Thanks a lot Buddy I'll take a look :)
rm4g00
Enthusiast
Posts: 39
Liked: never
Joined: Aug 02, 2016 11:58 am
Full Name: RM4G00
Contact:

Re: Failed Job status - automatic retry ?

Post by rm4g00 »

Can you just set this to look for the last result most recent as I think this will search for every failed task- basically all I'm looking for is to run a task scheduler to look for last result = failed then retry something simple
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Failed Job status - automatic retry ?

Post by veremin »

You can try this simple one-liner. It gets backup and replication jobs which latest session has Failed as its state and retry them:

Code: Select all

Get-VBRJob | where {$_.Jobtype -eq "Backup" -or $_.JobType -eq "Replica" -and $_.GetLastResult() -eq "Failed"} | Start-VBRJob -RetryBackup
Thanks.
rm4g00
Enthusiast
Posts: 39
Liked: never
Joined: Aug 02, 2016 11:58 am
Full Name: RM4G00
Contact:

Re: Failed Job status - automatic retry ?

Post by rm4g00 »

As always v.eremin- thank you :)
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Failed Job status - automatic retry ?

Post by veremin »

As always, you're welcome. :) If additional help is needed, don't hesitate to let us know. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests