PowerShell script exchange
Post Reply
sturmtr
Service Provider
Posts: 11
Liked: never
Joined: Jul 25, 2022 10:30 am
Contact:

List Vms in Backup Job

Post by sturmtr »

Hello,

I am trying to write a simple report that will show status of a specific backup job with its objects.
Objects (vms), VBR Server, Jobname, Status, Size, Comment

We are using vcloud backup type for nearly all of our jobs.

when I try the below script it produces vapp containers as virtual machines (due to job configuration)
Is it possible to find virtual machine but not vapp using GetObjectsInJob()?
Or can you provide a different approach?

Code: Select all

$JobsOutput = @()
$JobOutput = New-Object -TypeName PSObject
$JobNumber=0
$VMNumber=0
$JobList = Get-VBRJob -Name asdaf_* | Where {$_.GetLastState() -ne "Working" -and $_.JobType -eq "Backup"}
foreach($Jobobject in $JobList) {
	$JobName = $Jobobject.Name
	Write-Host "JOB: $JobName"
	$JobNumber++
	$VMList = $JobObject.GetObjectsInJob()
	foreach($VMObject in $VMList) {
		$VMName = $VMObject.name
		$JobOutput | Add-Member -Name "JobName" -MemberType Noteproperty -Value $JobName
		$JobOutput | Add-Member -Name "ClientName" -MemberType Noteproperty -Value $VMName
		$JobsOutput += $JobOutput
		Write-Host " ---> VMName: $VMName"
		$VMNumber++
	}
}
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: List Vms in Backup Job

Post by oleg.feoktistov »

Hi,

It's not possible with get objects method because it always gets only the entities that you directly added to a backup job.
Here you'd need to filter it out in vCD infrastructure by a vApp. For instance:

Code: Select all

$server = Get-VBRServer -Name 'vcd.local'
$job = Get-VBRJob -Name 'vCloud Backup'
$objects = Get-VBRJobObject -Job $job
foreach ($object in $objects) {
  $vms = Find-VBRvCloudEntity -Server $server -Vm | where {$_.vAppName -eq $object.Name}
  $vms
}
Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests