Recently I had to troubleshoot a Veeam Backup & Replication (B&R) problem. There the question popped up which are the running Veeam jobs at point or period of time. The GUI is not a big help to answer this question. Therefore I wrote a small script that show these jobs.
The following PowerShell script snippet is quite simple. First, start- (tStart
) and end-date/time (tEnd
) are asked for input. The following query selects all running Veeam jobs at point or period of time that matches input dates.
# Ask for start- and end-date and time
Write-Host "Enter date in format " ($(get-date).ToString("dd.MM.yyyy HH:mm"))
$tStart = Read-Host "Enter start-time (Enter for now)"
$tEnd = Read-Host "Enter end-time (Enter for equal to start-time)"
if ($tStart -eq '') {$tStart = get-date -Format "dd.MM.yyyy HH:mm"}
if ($tEnd -eq '') {$tEnd = $tStart}
# Check input data
try {$tStart = [DateTime]::Parse($tStart)}
catch {Write-Host "start-time wrong input"; continue}
try {$tEnd = [DateTime]::Parse($tEnd)}
catch {Write-Host "end-time wrong input"; continue}
if ($tStart -gt $tEnd) {Write-Host "start-time after end-time"}
# Load Veeam PowerShell Plugin
Add-PSSnapin VeeamPSSnapIn
# Connect to local Veeam Server
Connect-VBRServer -Server localhost
# Query jobs
Get-VBRBackupSession | Where-Object {($_.CreationTime -le $tStart -and ($_.EndTime -ge $tStart -or $_.EndTime -eq [DateTime]"1.1.1900")) `
-or ($_.CreationTime -ge $tStart -and $_.CreationTime -le $tEnd)} `
| select JobName, CreationTime, EndTime | Sort-Object Jobname | ft -AutoSize
# Disconnect from Veeam Server
Disconnect-VBRServer
Script Notes
- Script asks for date and time. You can just input date, time will be 00:00 than.
- To show all jobs running right now, just input blank start- and end-date.
- Command
Add-PSSnapin VeeamPSSnapIn
loads Veeam PowerShell Plugin. This is available at Veeam B&R server. - The connection to Veeam B&R is established by running
Connect-VBRServer
. When running this script at a Veeam B&R Server, connect tolocalhost
like here. To start this query at a Veeam B&R Server, you can run it as it is. - Script show these types of jobs:
- Backup jobs
- Replication jobs
- File copy jobs
- Backup copy jobs.
- If you use a different date/time format, take care it works for you. When not, change format options that way it fits to your format.
- If you want to doing further processing of the result of this script, remove
| Format-Table -AutoSize
at the end.
Notes