How to list Veeam VM backups with PowerShell? Recently I came across a use-case where you may want to list out all of the Virtual Machines (VMs) backed up with Veeam. If you have multiple Veeam servers that backup 100’s of VMs, creating a list of VMs and which server has their backups is useful. Additionally, that list could be searched or passed off to another team to do file restores. Instead of paying for VeeamOne to do this for you, this can be accomplished with PowerShell.
After some digging, I found a script on the Veeam forum that got me started here. That script gave me a little too much information, all I’m looking for is all the VMs and what job they are under. I trimmed the script and added an export to .csv; this is what I came up with.
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue
foreach($Job in (Get-VBRJob))
{
$Session = $Job.FindLastSession()
if(!$Session){continue;}
$Info = $Session.GetTaskSessions()
$allObjectsInJobs = ($info | ForEach-Object {$_} |
Where-Object {$_.status -eq "Success" -or $_.status -eq "Warning" -or $_.status -eq "Failed" -or $_.status -eq "InProgress"}) |
Foreach-object {$_ | Select-Object @{Name="Job";Expression={$Job.Name}},
@{Name="VM";Expression={$_.Name}}| Format-List | Out-String}
Write-Output $allObjectsInJobs | Out-File 'c:\temp\temp.csv' -encoding ascii -Append -NoNewline
}
Get-Content 'c:\temp\temp.csv' | Where { $_.Replace(",","") -ne "" } | Out-File 'c:\temp\VeeamVMsBackedUp.csv'
Remove-Item 'c:\temp\temp.csv'
The last part where the script creates a temp.csv is because I was getting 3-4 blank rows in the first csv file. The replace command removes that, exporting the final product to “VeeamVMsBackedUp.csv”.
That should help anyone to list Veeam VM backups with PowerShell.
You can get Veeam here.
Check out my previous blog post here.
This post was originally from my blog, referenced below.
Haven't joined Publish0x yet? Join up by using my referral code.
You can get a 25 PRE token bonus if you use my referral code here. This is to support a decentralized web search engine with presearch.org.
You can earn crypto at Odysee.com, an alternative to youtube. Use my affiliate link here to watch and earn.
God bless you!