I'm working on a project in which I need to generate a CSV file with the active Veeam Backup sessions to generate a dashboard later. I've managed to extract them for Backup, Backup to Tape, and Replication jobs, but I haven't been able to extract them for SOBR Tiering jobs. Can anyone provide me with the function or code to extract them? I'm using v12.3 and an Enterprise Plus license.
Thank you
My error:
Get-VBRObjectStorageTierSession : The term 'Get-VBRObjectStorageTierSession' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Code: Select all
# Carga el módulo de Veeam
Add-PSSnapin VeeamPSSnapIn -ErrorAction SilentlyContinue
$runningSessions = @()
# Backup estándar y replicación: Get-VBRBackupSession incluye tipos Backup y Replication
$backupAndReplicaSessions = Get-VBRBackupSession | Where-Object {
$_.State -in @("Working", "Starting", "Resuming", "Stopping", "Finalizing")
}
foreach ($session in $backupAndReplicaSessions) {
# Para replicación, usar JobType si disponible, sino asumimos Backup
$jobType = if ($session.GetType().Name -like "*Replica*") { "Replication" } else { "Backup" }
# Calcular ancho de banda
$startTime = $session.CreationTime
$endTime = Get-Date
$durationSeconds = [math]::Round(($endTime - $startTime).TotalSeconds, 2)
$bytesTransferred = $session.Progress.TransferedSize
if ($durationSeconds -gt 0 -and $bytesTransferred -gt 0) {
$bandwidthMbps = [math]::Round(($bytesTransferred * 8 / 1024 / 1024) / $durationSeconds, 2)
} else {
$bandwidthMbps = "N/A"
}
$runningSessions += [PSCustomObject]@{
JobName = $session.JobName
Progress = if ($session.BaseProgress -ne $null) { "$($session.BaseProgress)%" } else { "N/A" }
BandwidthUsage = $bandwidthMbps
JobType = $jobType
}
}
# Backup to Tape sesiones
$tapeJobs = Get-VBRTapeJob
foreach ($job in $tapeJobs) {
$sessions = Get-VBRTapeBackupSession -Job $job
$activeSessions = $sessions | Where-Object { $_.State -in @("Working", "Starting", "Resuming", "Stopping", "Finalizing") }
foreach ($session in $activeSessions) {
$startTime = $session.CreationTime
$endTime = Get-Date
$durationSeconds = [math]::Round(($endTime - $startTime).TotalSeconds, 2)
$bytesTransferred = $session.ProgressTransferredSize
if ($durationSeconds -gt 0 -and $bytesTransferred -gt 0) {
$bandwidthMbps = [math]::Round(($bytesTransferred * 8 / 1024 / 1024) / $durationSeconds, 2)
} else {
$bandwidthMbps = "N/A"
}
$runningSessions += [PSCustomObject]@{
JobName = $job.Name
Progress = if ($session.Progress -ne $null) { "$($session.Progress)%" } else { "N/A" }
BandwidthUsage = $bandwidthMbps
JobType = "Backup to Tape"
}
}
}
# SOBR Tiering sesiones (usando Get-VBRObjectStorageTierSession)
try {
$sobrSessions = Get-VBRObjectStorageTierSession | Where-Object {
$_.State -in @("Working", "Starting", "Resuming", "Stopping", "Finalizing")
}
foreach ($session in $sobrSessions) {
$startTime = $session.CreationTime
$endTime = Get-Date
$durationSeconds = [math]::Round(($endTime - $startTime).TotalSeconds, 2)
$bytesTransferred = $session.ProgressTransferredSize
if ($durationSeconds -gt 0 -and $bytesTransferred -gt 0) {
$bandwidthMbps = [math]::Round(($bytesTransferred * 8 / 1024 / 1024) / $durationSeconds, 2)
} else {
$bandwidthMbps = "N/A"
}
$runningSessions += [PSCustomObject]@{
JobName = $session.JobName
Progress = if ($session.Progress -ne $null) { "$($session.Progress)%" } else { "N/A" }
BandwidthUsage = $bandwidthMbps
JobType = "SOBR Tiering"
}
}
} catch {
Write-Host "No se pudo obtener sesiones SOBR Tiering. Puede que la versión de Veeam no lo soporte." -ForegroundColor Yellow
}
# Filtrar solo propiedades requeridas para exportar
$exportData = $runningSessions | Select-Object JobName, Progress, BandwidthUsage
# Ruta CSV
$csvPath = "C:\carlos\v17ListadoSesionesBackups.csv"
if ($exportData.Count -gt 0) {
$exportData | Export-Csv -Path $csvPath -NoTypeInformation -Force -Encoding UTF8
Write-Host "✅ Exportación completada: $csvPath" -ForegroundColor Cyan
} else {
Write-Host "No hay sesiones activas para exportar." -ForegroundColor Yellow
}
Thanks