PowerShell script exchange
Post Reply
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

Script to list all VMs and which jobs they are in

Post by ncolt »

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?
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov »

Hello Neil,
How about getting the desired info from Protected VMs Veeam ONE report rather than delve into scripts?
Thanks!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

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

Post by ncolt » 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
" "
}
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov »

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!
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

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

Post by ncolt »

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
}
" " 
}
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov »

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!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

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

Post by ncolt »

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.
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov » 1 person likes this post

Have you chosen all Virtual Infrastructure or just some VM folders in the scope?
Image
Thanks!
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

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

Post by ncolt »

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
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov »

Great!
If you think some other information would be useful and appropriate for the report, let me know. Thanks!
Flupke
Lurker
Posts: 1
Liked: never
Joined: Jul 17, 2015 8:53 am
Contact:

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

Post by Flupke »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
ncolt
Enthusiast
Posts: 32
Liked: 4 times
Joined: Apr 13, 2012 3:51 pm
Full Name: Neil Colthorpe
Contact:

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

Post by ncolt »

Great!
If you think some other information would be useful and appropriate for the report, let me know. Thanks!
Hi, just thought of what would be useful: a column with the backup repository so I can make sure each VM is backed up to the correct site.
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

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

Post by Shestakov »

ncolt wrote:Hi, just thought of what would be useful: a column with the backup repository so I can make sure each VM is backed up to the correct site.
It makes sense, we will add it in the next versions. Thanks for the request!
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

[MERGED] Listing VMs excluded from jobs

Post by marius roma »

I discovered that (for reasons still to be investigated) some VMs were excluded by jobs and are not processed.
Some VM were deliberately exluded, others were excluded automatically, maybe after errors.
How can I get a list of all the VM excluded by jobs without opening each single job?
Regards
marius
arkkis
Lurker
Posts: 1
Liked: never
Joined: Aug 01, 2017 10:44 am
Full Name: Jari Arkoma
Contact:

[MERGED] Exclusions in Get-VBRBackup (v9.5)?

Post by arkkis »

Hello,

is it somehow possible to get count of excluded VM's in a job?
Like Get-VBRBackup gives VmCount in job details, could there be count of excluded VM's, too? It would be handy (easy to script, at least) if it just shows ExcludedVmCount or something.

Enterprise manager reports page seems to leave excluded VM's out of VM Count. Something I try to do with Get-VBRBackup, too.

Br,
Jari
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

Use the example above to list VMs excluded from processing. Once those VMs are listed, you can easily count them. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests