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++
}
}