PowerShell script exchange
Post Reply
stsc_srzc
Enthusiast
Posts: 25
Liked: 2 times
Joined: Feb 21, 2013 11:53 am
Contact:

List all VMs defined in backup jobs for complete vc hosts

Post by stsc_srzc »

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

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

Post by veremin »

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:

http://forums.veeam.com/viewtopic.php?f=26&t=12714
http://forums.veeam.com/viewtopic.php?f=26&t=12870

Hope this helps.
Thanks.
stsc_srzc
Enthusiast
Posts: 25
Liked: 2 times
Joined: Feb 21, 2013 11:53 am
Contact:

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

Post by stsc_srzc »

Hi v.Eremin,

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

Regards
Stefan
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests