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

PowerShell script exchange

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

Veeam Logoby serverbu » Wed 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
serverbu
Enthusiast
 
Posts: 38
Liked: 4 times
Joined: Wed Feb 19, 2014 4:30 pm

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

Veeam Logoby v.Eremin » Wed 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby serverbu » Wed 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.
serverbu
Enthusiast
 
Posts: 38
Liked: 4 times
Joined: Wed Feb 19, 2014 4:30 pm

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

Veeam Logoby v.Eremin » Wed 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.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby serverbu » Thu 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.
serverbu
Enthusiast
 
Posts: 38
Liked: 4 times
Joined: Wed Feb 19, 2014 4:30 pm

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

Veeam Logoby v.Eremin » Thu Feb 12, 2015 1:54 pm

Glad to hear my input was helpful. Don't hesitate to ask, should other assistance be needed.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests