PowerShell script exchange
Post Reply
serverbu
Enthusiast
Posts: 38
Liked: 4 times
Joined: Feb 19, 2014 4:30 pm
Contact:

Q: Is there a cmdlet to get jobs a vm is in

Post by serverbu » Feb 04, 2015 11:48 am

Hello,

as the title implicates, we want to get all the jobs a specific vm is in.

'Till now we do this with a Get-VBRJob to get names of all jobs and pass this list, jobname by jobname through a loop, to Get-VBRJobObject and compare all vm-names in the result list with the one we are looking for, to see if the specific vm is in that job. If so the script returns the jobs name and Get-VBRJobObject is called with the next job name from Get-VBRJob.

Is there a more direct approach through a cmdlet? We've looked for something like '

Code: Select all

Get-VMsJobNames -name "VM Name"
' or '

Code: Select all

Find-JobsOfVM -name "VM Name"
' or likewise cmdlets but didn't found any cmdlet in help or documentation that implicateted such usage through its name.

Best regards

v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Q: Is there a cmdlet to get jobs a vm is in

Post by v.Eremin » Feb 04, 2015 2:07 pm

There is no need in additional commandlet, as everything can be done via the following one-liner:

Code: Select all

Get-VBRJob | ?{$_.GetObjectsInJob().name -eq "Name of VM"} | select name
Thanks.

serverbu
Enthusiast
Posts: 38
Liked: 4 times
Joined: Feb 19, 2014 4:30 pm
Contact:

Re: Q: Is there a cmdlet to get jobs a vm is in

Post by serverbu » Feb 11, 2015 10:03 am

Code: Select all

Get-VBRJob | ?{$_.GetObjectsInJob().name -eq "Name of VM"} | select name
What exactly is returned by this?
I tried this with each and every vm name we have in any job, but it didn't seem to return anything at all.

v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Q: Is there a cmdlet to get jobs a vm is in

Post by v.Eremin » Feb 11, 2015 11:20 am

The provided script returns names of jobs that have VM with the defined name as their source. Are you using individual VMs or containers (folders, resource pools, hosts, etc.) as jobs' source? What product version you're using? Thanks.

serverbu
Enthusiast
Posts: 38
Liked: 4 times
Joined: Feb 19, 2014 4:30 pm
Contact:

Re: Q: Is there a cmdlet to get jobs a vm is in

Post by serverbu » Feb 12, 2015 1:04 pm

The Problem was caused by a misstype in the script. After I corrected my misstype I got the expected result.

Thanks for your help.

v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Q: Is there a cmdlet to get jobs a vm is in

Post by v.Eremin » Feb 12, 2015 1:54 pm

Glad to hear my input was helpful. Don't hesitate to ask, should other assistance be needed.

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests