My object to prepare a report that will look like this
JobName VMName JobType LastBackupResult LastBackupDate NumberOfRestorePOints
I started with below code
Code: Select all
$vms = (get-vbrbackup -name aecl*).GetObjects() | select name
foreach($Vm in $vms){
$RP = Get-VBRRestorePoint -Name $vm.Name
$RPCount = $RP | Measure-Object
new-object PSObject -property @{
"name" = $RP.name | select -First 1 | sort name
"Restore Point" = $RPCount.Count
}
}
Code: Select all
$details = @()
$jobname = @("JobA", "JobB", "JobC", "JObD")
$jobs = Get-VBRJob -Name $jobname
foreach ($job in $jobs){
$vms = Get-VBRJobObject -Job $job
foreach($Vm in $vms){
$RP = Get-VBRRestorePoint -Name $vm.Name
$RPCount = $RP | Measure-Object
$columns = New-Object psobject
$columns | Add-Member -MemberType NoteProperty -Name "Job Name" -Value $job.Name
$columns | Add-Member -MemberType NoteProperty -Name "Job Type" -Value $job.JobType
$columns | Add-Member -MemberType NoteProperty -Name "Last Backup Result" -Value $job.GetLastResult()
$columns | Add-Member -MemberType NoteProperty -Name "serverName" -Value $RP.vmname | select -First 1
$columns | Add-Member -MemberType NoteProperty -Name "Count" -Value $RP.count
$details += $columns
}
}
Disconnect-VBRServer
$details | Export-Csv c:\temp\report.csv
Job Name Job Type Last Backup Result server Name Count
JObA Backup Warning System.Object[] 90
One ore thing I would like to add here once script execution finished, I ran only $RP.vmname | select -First 1 and it is showing the VM name.
Not sure what is wrong with the code. We are using VBR V10.
Thanks in advance!