I am creating a report on counting the restore points per backup job.
However, upon using this script, the result is different from what I want.
The result of the output looks like this:
Job Name Job Type Last Backup Result Server Name Count
Server_D EpAgentBackup Success 0
Server_VM Backup Success Server 25
All of the restore points of "Server" is being counted for the jobname Server_VM.
It should be:
Server_D count = 18
Server_VM count = 7
The backup is File level and VM level, hence the "Server_D" - from D: drive and "Server_VM" for the VM itself.
It there a way to count for different job name and not for the vm name?
Code: Select all
$details = @()
$jobname = @("Server_D", "Server_VM")
$jobs = Get-VBRJob -Name $jobname
$backups = Get-VBRBackup
$rps = Get-VBRRestorePoint
foreach ($job in $jobs) {
$backup = $backups | Where-Object {$_.JobId -eq $job.id}
$vms = $backup.GetObjectOibsAll()
foreach ($vm in $vms) {
$rp = $rps | Where-Object {$_.vmname -eq $vm.Name}
$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 "Server Name" -Value $vm.name
$columns | Add-Member -MemberType NoteProperty -Name "Count" -Value $rp.count
$details += $columns
}
}
Disconnect-VBRServer
$details | Export-Csv c:\temp\report.csv
powershell-f26/count-number-of-restore- ... 67754.html
Thanks in advance.