-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
PowerShell script to monitor running jobs
Hello,
In my setup I have about 10 backup jobs. I would like to start a HP Data Protector job after the last job finishes. So ideally I would run a post job script which starts the HP Data Protector job. My problem is that when the last Veeam job is completed earlier jobs might still be running.
So I was searching the forum to see if I could find a PowerShell script providing this functionality. I couldn’t find one .
Ideas?
Cheers,
In my setup I have about 10 backup jobs. I would like to start a HP Data Protector job after the last job finishes. So ideally I would run a post job script which starts the HP Data Protector job. My problem is that when the last Veeam job is completed earlier jobs might still be running.
So I was searching the forum to see if I could find a PowerShell script providing this functionality. I couldn’t find one .
Ideas?
Cheers,
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
That is strange, because I can see all the latest forum searches, and there are no relevant onesMarcel wrote:So I was searching the forum to see if I could find a PowerShell script providing this functionality. I couldn’t find one
There are many existing topics with sample scripts querying job status, just search for powershell job status
Also, you may want to check out this sample script for tape backup integration.
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
http://tinyurl.com/44hvsg9That is strange, because I can see all the latest forum searches, and there are no relevant ones
There are many existing topics with sample scripts querying job status, just search for powershell job status
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
The scipt you pointed out is not what I'm looking for.
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
I understand, this just for your reference, as this is what most people are using.
Regarding querying job status, just search the forum for powershell job status
Regarding querying job status, just search the forum for powershell job status
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: PowerShell script to monitor running jobs
You would want to do something like the following:
You could have this in your script to cycle through all your jobs like the following:
That will cycle through all your jobs and get the latest state.
Code: Select all
$Job = Get-VBRJob | ?{$_.name -eq "JobName"}
$Job.GetLastState()
Code: Select all
foreach ($v in (Get-VBRJob)){$v.GetLastState()}
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
Thank you both for the help. I'm going to write a script for this costumer. If i'm able to produce a usable script I will post it here.
Thanks,
Thanks,
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
This is the script i'm testing now. Seems to be working for me.
Would be a nice feature in the next release. A little checkbox in the post job activity screen "Only run when no jobs are running" would be enough for me.
Edit: I would be realy nice to have a job chaining feature in the next release. @Veeam please see this as a feature request.
Code: Select all
Add-PSSnapin Veeampssnapin
$JobActive=0
Do {
foreach ($v in (Get-VBRJob))
{
$JobStatus = ($v.GetLastState())
If ($JobStatus -notlike "Stopped"){$JobActive ++}
}}
while($JobActive -notlike "0")
#Insert backup command here
Edit: I would be realy nice to have a job chaining feature in the next release. @Veeam please see this as a feature request.
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
Why do you need job chaining, Marcel?
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: PowerShell script to monitor running jobs
We do have "job chaining" so to speak. If you go to properties -> Next until the last page that says "Summary". You can grab the command line string and place it into the "post job" script for another job. From here, one job will kick off another.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
Ik know the command is in the summary tab, thanks.
I think it would be nice to have chaining in the interface because not all customers are able to create en maintain (powershell) scripts.
I think it would be nice to have chaining in the interface because not all customers are able to create en maintain (powershell) scripts.
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: PowerShell script to monitor running jobs
Chaining jobs together with the command in the summary tab doesn't require any powershell. If you want to make sure other jobs aren't running or special things, then that currently requires powershell:)
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
Marcel, my question is more about why do you need the ability to chain. I would like to understand your use case behind it. Thanks.
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
Anton, maybe chaining isn’t the right word. Let’s call it grouping. Grouping lets us put multiple jobs in a group. One feature of a group is the ability to set a post command after all the jobs in this group are done (regardless of the result).
Another nice feature of a group would be to set (besides a post job command) some of the settings for all the jobs in the group for example VSS credentials, Restore points etc.
You might say “There is a job for, you don’t need group”. When we install Veeam at large customers (200+ vm’s) we need to create multiple jobs. In the past we created one job for a lot of VM’s. We noticed this is not always the best way to go. One reason for this is file corruption. In the past we had file corruption a few times. The only way to resolve this was to create a new full backup. This can take a long time when we are talking about more the 15TB.
I hope the above is clear.
Another nice feature of a group would be to set (besides a post job command) some of the settings for all the jobs in the group for example VSS credentials, Restore points etc.
You might say “There is a job for, you don’t need group”. When we install Veeam at large customers (200+ vm’s) we need to create multiple jobs. In the past we created one job for a lot of VM’s. We noticed this is not always the best way to go. One reason for this is file corruption. In the past we had file corruption a few times. The only way to resolve this was to create a new full backup. This can take a long time when we are talking about more the 15TB.
I hope the above is clear.
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
Marcel, thanks for the detailed explanation.
-
- Influencer
- Posts: 11
- Liked: 2 times
- Joined: Aug 10, 2011 8:58 am
- Full Name: Marcel Nobel
- Contact:
Re: PowerShell script to monitor running jobs
Additional question. Is it possible to set a working directory for the post job command?
-
- Chief Product Officer
- Posts: 31814
- Liked: 7302 times
- Joined: Jan 01, 2006 1:01 am
- Location: Baar, Switzerland
- Contact:
Re: PowerShell script to monitor running jobs
If it is BAT file, then just put in the first line:
Code: Select all
cd /d C:\Directory
Who is online
Users browsing this forum: No registered users and 15 guests