I have a problem, it’s been several days that I’ve been trying to create a script that returns the actions of the last backup copy. Here’s the script I’ve made so far, the problem is that it only works for normal backups. Here it is:
Code: Select all
$cred = Import-Clixml -Path "**************"
Connect-VBRServer -Server "******" -Credential $cred
Import-Module Veeam.Backup.PowerShell -ErrorAction SilentlyContinue
$jobName = Read-Host "Write the name of your backup copy"
$job = Get-VBRJob | Where-Object { $_.Name -eq $jobName }
if (-not $job) {
$job = Get-VBRBackupCopyJob | Where-Object { $_.Name -eq $jobName }
}
if (-not $job) {
Write-Host "No job with this name : '$jobName'"
Disconnect-VBRServer
return
}
$lastSession = $job.FindLastSession()
if (-not $lastSession) {
Write-Host "No session for this job : '$jobName'"
Disconnect-VBRServer
return
}
if ($lastSession) {
foreach ($task in $lastSession.GetTaskSessions()) {
$task.Logger.GetLog().UpdatedRecords |
Select-Object @{Name="VM"; Expression = { $task.Name }},
StartTime,
Status,
Title,
Action |
Sort-Object StartTime |
Format-Table -AutoSize
}
}
Disconnect-VBRServer