VEEAM - Export Job Sessions (logs) by Keyword

cls Write-Host "VEEAM - Export Job Sessions by Keyword" -BackgroundColor DarkRed -ForegroundColor Yellow Write-Host "Wait...Wait...Wait..." Write-Host # Define the keyword that is common to all the jobs, date and path to file $Keyword = "DB" $date = (Get-Date).ToString('yyyy-MM-dd') $folderPath = "C:\Backup\" # Get the date for desired days ago $OneYearAgo = (Get-Date).AddYears(-1) # Get all jobs that contain the keyword in their name $Jobs = Get-VBRJob | Where-Object {$_.Name -like "*$Keyword*"} # Get all sessions $AllBackupSessions = Get-VBRBackupSession # The longest part of the script Write-Host "I'm going to export all jobs with keyword $Keyword" -ForegroundColor Green foreach ($Job in $Jobs) { $BackupSessions = "" $filePath = "" $JobName = $Job.name Write-Host Write-Host "JobName: $JobName" # Get all sessions for the specified job from the past specified days $BackupSessions = $AllBackupSessions | Where-Object {$_.JobName -eq $JobName -and $_.CreationTime -gt $OneYearAgo} | Select-Object OrigJobName, CreationTime, EndTime, Result, State, LogsSubFolder, LogName, Description # Export sessions to a CSV file $filePath = $folderPath+$JobName+"_"+$date+"."+"csv" $BackupSessions | Export-Csv -Path $filePath -NoTypeInformation } start $folderPath Write-Host Write-Host "END!"

Comments

Popular posts from this blog

VEEAM GUI - single Tape Job sessions.1.0

PowerCLI Amateur declaration

VEEAM GUI - single Job sessions.1.0