PowerShell script exchange
Post Reply
david.domask
Product Manager
Posts: 3589
Liked: 866 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 » 2 people like 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
RubinCompServ
Service Provider
Posts: 440
Liked: 154 times
Joined: Mar 16, 2015 4:00 pm
Full Name: David Rubin
Contact:

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

Post by RubinCompServ »

Thank you for this! However, using Get-VBRSession will cause all sessions to get returned, which will substantially increase the amount of time it takes the script to run, won't it?
RubinCompServ
Service Provider
Posts: 440
Liked: 154 times
Joined: Mar 16, 2015 4:00 pm
Full Name: David Rubin
Contact:

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

Post by RubinCompServ »

But if we (try to) pass the job object from Get-VBRJob to Get-VBRSession, aren't we right back where we started?
david.domask
Product Manager
Posts: 3589
Liked: 866 times
Joined: Jun 28, 2016 12:12 pm
Contact:

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

Post by david.domask »

Ah, I have not had enough coffee and my thoughts got crossed =,= You're correct, I'll delete my post since it's non-sense.

Currently we don't have a way to get it faster, but the purpose of this exercise was to have a fully supported method for retrieving these sessions, and it should still be considerably faster than Get-VBRBackupSession.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: AdsBot [Google], Bing [Bot] and 25 guests