PowerShell script exchange
Post Reply
david.domask
Product Manager
Posts: 3489
Liked: 841 times
Joined: Jun 28, 2016 12:12 pm
Contact:

[How To] Supported Method for Session Reporting on all Job Types (including Proxmox, Nutanix, etc)

Post by david.domask » 1 person likes this post

Sharing this tidbit here as there are quite a few topics on how to do session reporting on all job types including the plugin-based Hypervisors (aka PlatformBackups, for example Proxmox, Nutanix, HPE Morpheus, etc)

Normally you would pass a CJob object from Get-VBRJob to Get-VBRSession -Job, but regrettably this will currently error with many job types:
Get-VBRSession: Cannot bind parameter 'Job'. Cannot convert value "Veeam.Backup.Core.CBackupJob" to type "Veeam.Backup.PowerShell.Infos.VBRJob". Error: "The given key 'VmbApiPolicyTempJob' was not present in the dictionary."
However, we can do a little magic trick with Get-VBRSession on the -Type parameter to get all PlatformBackup jobs; Get-VBRSession returns "light" information on the session data, so we will do another magic trick to get full session data from Get-VBRBackupSession, which in turn can be passed to Get-VBRTaskSession for full session reporting with supported methods.

Code: Select all

$allSess = Get-VBRSession -Type PlatformBackupJob
$realAllSess = Get-VBRBackupSession -Id $allSess.Id | Where-Object {$_.Platform.ToHumanReadable() -Like "Proxmox*"} # Comment 0
$jobId = $realAllSess.JobId | Sort-Object -Unique
 
 
#Get most recent job session for each Proxmox JobId, and each individual task session from that most recent session
 
$lastSessionReport = @()
ForEach($j in $jobId){
	$lastSess = $realAllSess | Where-Object {$_.JobId -eq $j} | Sort-Object -Property CreationTime -Descending | Select -First 1 #this line returns only most recent Job Session
	$tSess = Get-VBRTaskSession -Session $lastSess
	Foreach($t in $tSess){
		$data = [PSCustomObject]@{
			VMName = $t.Name
			Result = $t.status
			RestorePointCreationTimeUtc = $t.Info.Progress.StartTimeUtc
		}
		$lastSessionReport += $data
		Remove-Variable data
	}
	Remove-Variable tSess
	Remove-Variable lastSess
}


<#
[0] - For the Where filter, we can filter on following HumanReadable Platform Names like in the example; example shows how to get Proxmox jobs, but edit that line with an entry from below to get other types.

Windows
Linux
Mac
Unix
SAP HANA
SAP HANA Linux
SAP HANA Linux on Power
SAP on Oracle
SAP on Oracle Linux
Oracle RMAN
RMAN Linux
RMAN Windows
Microsoft SQL
IBM Db2
IBM Db2 Linux
IBM Db2 Linux on Power
IBM Db2 Windows
SMB share
NFS share
AWS EC2
Azure IaaS
SAP MaxDB
SAP MaxDB Linux
SAP MaxDB AIX
GCE
Kasten
Nutanix AHV
Proxmox VE
SC HyperCore
XCP-ng
HPE Morpheus VME
Sangfor HCI
RHV
#>
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests