PowerShell script exchange
Post Reply
theirpuppet
Influencer
Posts: 10
Liked: never
Joined: Jan 20, 2020 10:16 am
Full Name: DR
Contact:

Get-VBRJobObject and "vm folders"

Post by theirpuppet »

Hello, I have a Backup Job that is configured with a single object: a vSphere 'VM Folder'. Unfortunately, Get-VBRJobObject only outputs that folder - not the VMs inside the folder.

Is there a Veeam provided CMDLET or mechanism to enumerate those VMs contained in that VM Folder?

Some interesting properties of the returned VBRJobObject (if they are relevant). Despite "isFolder = False", let me assure you that this is a VM Folder. It is not a Resource Pool or other object.
  • $vbrjobobj.isFolder = False
  • $vbrjobobj.Object.ViType = 'Folder'
  • $vbrjobobj.Object.Type = 'Directory'
  • $vbrjobobj.Object.Info.IsDirectory = True
  • $vbrjobobj.Object.Info.IsFile = False

:)
Thanks in advance!
Egor Yakovlev
Product Manager
Posts: 2581
Liked: 708 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Get-VBRJobObject and "vm folders"

Post by Egor Yakovlev »

Hi,
objects like VM Folders, Resource Pools, Datastores are dynamic - that is, Veeam does not know which VMs are currently in said folder\pool\datastore and we will query that information from vsphere each time job starts. So answer to your question is no, there is no Veeam Powershell cmdlet to query that information.
- you can query same info using vSphere PowerCLI cmdlet instead (Get-VM -Location $YourVMFolder)
- you can query Veeam job result(from sessions), and it will tell you which VMs were processed as a result of said job, however, note that it will not reflect current production state of said object, as it could change after backup job completion.
Hope that helps!
theirpuppet
Influencer
Posts: 10
Liked: never
Joined: Jan 20, 2020 10:16 am
Full Name: DR
Contact:

Re: Get-VBRJobObject and "vm folders"

Post by theirpuppet »

Thanks, Egor. But I have found a solution:

$job = get-vbrjob -name "xxx"
$bkp = get-vbrbackup | Where-object {$_.jobid -eq $job.id}
$bkp.getobjects()

If I use the associated VBRBackup, I am able to retrieve the objects.
NB, the above is pseudo-code .. it may be syntactically incorrect.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Get-VBRJobObject and "vm folders"

Post by jhoughes »

There are some potential problems with that method, as a VM will only display after a backup job has run. It may also display VMs that were included in a backup previously, but may no longer be contained within a job.

Just be aware that it may not be 100% accurate, and it would only be accurate after the job runs if either job objects are changed, or if VMs are moved within the virtual environment.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
theirpuppet
Influencer
Posts: 10
Liked: never
Joined: Jan 20, 2020 10:16 am
Full Name: DR
Contact:

Re: Get-VBRJobObject and "vm folders"

Post by theirpuppet »

Thanks for the input, jhoughes.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests