List all VMs defined in backup jobs for complete vc hosts

PowerShell script exchange

List all VMs defined in backup jobs for complete vc hosts

Veeam Logoby stsc_srzc » Thu Feb 21, 2013 12:45 pm

Hi everyone!

I am trying to get a list of all VMs registred in my backup jobs. Some of the jobs have an complete ESX host as the object to backup and some even a complete VC server as the object to backup. My code below gives me the name of the objects to backup in the jobs. Is there a way to tell what "Location" is (eg. vm, ESX server, VC-Server)? By knowing that location is eg. an ESX server I could than easily add all VMs on that server to my backup list.

Code: Select all
$jobs = Get-VBRJob
foreach ($job in $jobs) {
    $objects = $job.GetObjectsInJob()
    foreach ($object in $objects) {
        write-host "jobname ["$job.Name"] location ["$object.Location"]"
    }
}



With regards
Stefan
stsc_srzc
Influencer
 
Posts: 10
Liked: 1 time
Joined: Thu Feb 21, 2013 11:53 am

Re: List all VMs defined in backup jobs for complete vc host

Veeam Logoby v.Eremin » Thu Feb 21, 2013 1:33 pm

Is there a way to tell what "Location" is (eg. vm, ESX server, VC-Server)?

If I’ve understood you correctly, object.type parameter is likely to answer your requirements.

Code: Select all
asnp VeeamPSSnapIn
$JobObject = Get-VBRJob -name "Name of your job" | Get-VBRJobObject
$JobObject.Object.Type

As a result:

“VC” will be returned, if you’re backing up VC as the whole.
“ESXi”, in case of ESXi host being backed up.
“VM”, if single VMs are chosen to be backed up.

Futhermore, it might be worth reviewing existing topics provided below in order to find possible solution:

viewtopic.php?f=26&t=12714
viewtopic.php?f=26&t=12870

Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List all VMs defined in backup jobs for complete vc host

Veeam Logoby stsc_srzc » Thu Feb 21, 2013 2:58 pm

Hi v.Eremin,

thank you for your reply. This is exactly the information I was looking for. Thank you very much.

Regards
Stefan
stsc_srzc
Influencer
 
Posts: 10
Liked: 1 time
Joined: Thu Feb 21, 2013 11:53 am


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests