PowerShell script exchange
Post Reply
cmcruz007
Novice
Posts: 3
Liked: never
Joined: Sep 06, 2025 9:49 am
Full Name: Carlos Cruz
Contact:

Extract active SOBR sessions to CSV

Post by cmcruz007 »

Hi everyone!
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
}
I have also tried ‘Import-Module Veeam.Backup.PowerShell’, but without success. Can someone help me?

Thanks
oleg.feoktistov
Veeam Software
Posts: 2035
Liked: 678 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Extract active SOBR sessions to CSV

Post by oleg.feoktistov »

Hi Carlos,

Get-VBRObjectStorageTierSession isn't some cmdlet that exists in VBR PS module. We don't have a dedicated one for SOBR tiering sessions, but you can query them this way:

For offloads to capacity tier

Code: Select all

Get-VBRSession -Type ArchiveBackup
For offloads to archive tier

Code: Select all

Get-VBRSession -Type ArchiveFreezing
Now, I see in your script that you are querying for bytes transferred. Unfortunately, Get-VBRSession doesn't show such info unless something is available in the session log records.
And here is the sample to check tiering session log:

Code: Select all

$session = Get-VBRSession -Type ArchiveBackup
$session[0].Log
Best regards,
Oleg Feoktistov
cmcruz007
Novice
Posts: 3
Liked: never
Joined: Sep 06, 2025 9:49 am
Full Name: Carlos Cruz
Contact:

Re: Extract active SOBR sessions to CSV

Post by cmcruz007 »

Thanks Oleg.

One question, Would it be easier to obtain this data with the REST API? I need to extract jobs such as

- Backup,
- Replication,
- Copy,
- Tape,
- Agents, and
- SOBR Tiering

that are running in real time, into a csv file.

Thanks!
david.domask
Veeam Software
Posts: 2975
Liked: 687 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Extract active SOBR sessions to CSV

Post by david.domask »

Hi cmcruz007,

I will step in and answer for Oleg here as seems thread maybe got lost.

Either should work, though REST API has some limitations right now in v13 (Tape primarily I believe) which we plan to address in later releases.

Powershell however will have cmdlets for all the endpoints you mentioned.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests