PowerShell script exchange
Post Reply
asif.khan@nxtgen.com
Lurker
Posts: 1
Liked: never
Joined: Jul 31, 2023 3:34 am
Full Name: Asif Khan
Contact:

Request for PowerShell Command to Retrieve VM Backup Details in Veeam

Post by asif.khan@nxtgen.com »

Hello everyone,

I'm seeking assistance to retrieve detailed backup information for VMs in Veeam, similar to what's visible under the disk job name property in the Veeam console. Specifically, I need a PowerShell command that can pull information about all backed-up VMs for a particular job, including each VM's monthly backup details, such as the date, original size, and backup size.

Could someone guide me on how to achieve this using PowerShell? Any example scripts or pointers to the right Veeam PowerShell cmdlets would be greatly appreciated.

Thanks in advance for your help!
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Request for PowerShell Command to Retrieve VM Backup Details in Veeam

Post by oleg.feoktistov »

Hi Asif,

A simple example of such script would look like that:

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $storages = $backup.GetAllChildrenStorages()
  foreach ($storage in $storages) {
    $rp = $storage.GetOibs()
    $originalSize = [Math]::Round($rp.ApproxSize/1GB, 2)
    $backupSize = [Math]::Round($storage.Stats.BackupSize/1GB, 2)
    $rp | select Name, @{n='OriginalSize';e={$originalSize}}, @{n='FileName';e={$storage.PartialPath}}, `
    @{n='CreationTime';e={$storage.CreationTime}}, @{n='BackupSize';e={$backupSize}}
  }
}
Then, you can filter the data out by the relevant date you need:

Code: Select all

$currentDate = Get-Date
$rp | select Name, @{n='OriginalSize';e={$originalSize}}, @{n='FileName';e={$storage.PartialPath}}, `
@{n='CreationTime';e={$storage.CreationTime}}, @{n='BackupSize';e={$backupSize}} | `
where {$storage.CreationTime -ge $currentDate.AddMonths(-1) }
Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests