Script to list all VMs and which jobs they are in

PowerShell script exchange

Script to list all VMs and which jobs they are in

Veeam Logoby ncolt » Thu Jul 09, 2015 10:27 am

Pretty much everyday I would use a report which shows all the VMs and which jobs they are in. I could simply do a ctrl + f and instantly see what job a given VM is protected by. This was tackled back in 2012 on these forums but I could not get this to work and it carries other baggage I do not need.

Please could someone give me a Powershell script to pull just this data out?
ncolt
Enthusiast
 
Posts: 31
Liked: 4 times
Joined: Fri Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Shestakov » Thu Jul 09, 2015 11:27 am

Hello Neil,
How about getting the desired info from Protected VMs Veeam ONE report rather than delve into scripts?
Thanks!
Shestakov
Veeam Software
 
Posts: 5034
Liked: 419 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Script to list all VMs and which jobs they are in

Veeam Logoby v.Eremin » Thu Jul 09, 2015 11:34 am

Speaking about the scripts, the following one will list job names along with names of their objects:

Code: Select all
Asnp VeeamPssnapin
Foreach ($Job in Get-VBRJob)
{
$Job | select name, {$_.GetObjectsInJob().name} | ft
}


However, it might be a better idea to leverage the script provided here.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13563
Liked: 1007 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to list all VMs and which jobs they are in

Veeam Logoby ncolt » Thu Jul 09, 2015 1:00 pm 1 person likes this post

Thanks. I've slightly modified the last script, but it shows the folder objects instead of the VMs, and VMs only if they are specified. The Veeam One reporting isn't working for me at the moment, I'll log a call to get that fixed, although that's more long-winded than Powershell which I can schedule with my "backed up by Veeam" script.

Code: Select all
Foreach ($Job in Get-VBRJob)
{
$job | select name
"-------------------"
$Job |select @{Name="Objectsinjob";Expression={$_.GetObjectsInJob().name}} | select -expandproperty Objectsinjob
" "
}
ncolt
Enthusiast
 
Posts: 31
Liked: 4 times
Joined: Fri Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe

Re: Script to list all VMs and which jobs they are in

Veeam Logoby v.Eremin » Thu Jul 09, 2015 2:21 pm

VMs belonging to a specific folder can be gotten via the following one-liner:

Code: Select all
Find-VBRViEntity -VMsAndTemplates -Server (Get-VBRServer -Name "Name of your VC") | where {$_.VmFolderName -eq "Name of your folder"}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13563
Liked: 1007 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Shestakov » Thu Jul 09, 2015 2:42 pm

ncolt wrote:The Veeam One reporting isn't working for me at the moment, I'll log a call to get that fixed

Could you specify the problem with Veeam One? Have you contacted Veeam technical support with that?
Thanks!
Shestakov
Veeam Software
 
Posts: 5034
Liked: 419 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Script to list all VMs and which jobs they are in

Veeam Logoby ncolt » Mon Jul 13, 2015 1:54 pm

Could you tell me what the best report in Veeam One is for this? I've tried VM > protected VMs Job Schedule but the Backup Job column is in some kind recurring loop which has nothing to do with the VMs column.

The script is getting there although as it calls PowerCLI get-view for the contents of folders (for speed) it cannot not tell you which VMs are excluded, please could you tell me the Veeam command for that so i can integrated this information e.g. get-vbrjob| select excluded

Code: Select all
Foreach ($Job in Get-VBRJob)
{
$job | select name
"-------------------"
"Foldername"
$foldername= $Job | select @{Name="Objectsinjob";Expression={$_.GetObjectsInJob().name}} | select -expandproperty objectsinjob
$foldername
" "
$check=get-view -viewtype folder -filter @{"name"="$foldername"}

if ($check)
{
"VMs in folder";
$check.ChildEntity | get-viobjectbyviview | select name
}
" "
}
ncolt
Enthusiast
 
Posts: 31
Liked: 4 times
Joined: Fri Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Shestakov » Mon Jul 13, 2015 2:28 pm

Neil,
As I stated above Protected VMs as it shows explicitly which VMs are not protected and which VMs belong to the shown jobs. Please check if it`s suitable for you.
Protected VMs job schedule report is more about planning.
Thanks!
Shestakov
Veeam Software
 
Posts: 5034
Liked: 419 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Script to list all VMs and which jobs they are in

Veeam Logoby v.Eremin » Mon Jul 13, 2015 4:25 pm

The script is getting there although as it calls PowerCLI get-view for the contents of folders (for speed)

You mean native PowerCLI commandlet work faster than Find-VBRViEntity does?

it cannot not tell you which VMs are excluded

Excluded objects have IsExcluded parameter equal to $True:

Code: Select all
$Job.GetObjectsInJob() | where {$_.isexcluded -eq $true}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13563
Liked: 1007 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to list all VMs and which jobs they are in

Veeam Logoby ncolt » Wed Jul 15, 2015 12:46 pm

Neil,
As I stated above Protected VMs as it shows explicitly which VMs are not protected and which VMs belong to the shown jobs. Please check if it`s suitable for you.
Protected VMs job schedule report is more about planning.
Thanks!


OK, I ran report: VM > Protected VMs. Says there are total VMs 93 (there are a lot more than that). Says protected VMs are 76. The daily script I use from Shawn Masterson says have over 400 protected VMs.
ncolt
Enthusiast
 
Posts: 31
Liked: 4 times
Joined: Fri Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Shestakov » Wed Jul 15, 2015 1:08 pm 1 person likes this post

Have you chosen all Virtual Infrastructure or just some VM folders in the scope?
Image
Thanks!
Shestakov
Veeam Software
 
Posts: 5034
Liked: 419 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Script to list all VMs and which jobs they are in

Veeam Logoby ncolt » Wed Jul 15, 2015 1:39 pm

Yay, that got it. I set RPO to 1 day and looks like it's got them all. Shows available restore points as a bonus :D

Thanks

Neil
ncolt
Enthusiast
 
Posts: 31
Liked: 4 times
Joined: Fri Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Shestakov » Wed Jul 15, 2015 4:07 pm

Great!
If you think some other information would be useful and appropriate for the report, let me know. Thanks!
Shestakov
Veeam Software
 
Posts: 5034
Liked: 419 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Script to list all VMs and which jobs they are in

Veeam Logoby Flupke » Fri Jul 17, 2015 1:23 pm

I want to write a script that compares all the backup's in Veeam to the list from VMware.

Now tested all the script mentioned on this topis but did not do the job.

They all include the server who are excluded. We speak about +200 servers

Image

Now I need a script that list up all servers from all backup jobs, weh have a 30 different jobs (1) and from all of those jobs I need to get all servers (2) in a list.

regards
Flupke
Lurker
 
Posts: 1
Liked: never
Joined: Fri Jul 17, 2015 8:53 am

Re: Script to list all VMs and which jobs they are in

Veeam Logoby v.Eremin » Fri Jul 17, 2015 2:22 pm

Have you taken a look at the one-liner that is supposed to list excluded servers? Using that list you can compare it then to list of existing backup job objects and exclude those that are present into both lists. Thanks.
v.Eremin
Veeam Software
 
Posts: 13563
Liked: 1007 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests