PowerShell script exchange
Post Reply
sebastien MULOT
Novice
Posts: 7
Liked: never
Joined: Nov 15, 2021 10:31 am
Contact:

CSV report

Post by sebastien MULOT »

Hello,
I will want to get an Excel table with its information in addition to what this script provides, to know the total disk volume occupied by the backup and the vhdx of each VM (for accounting and invoicing):

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $storages = $backup.GetAllStorages()
  foreach ($storage in $storages) {
    $storage | select @{n='Name';e={$_.PartialPath}}, @{n='DataSize';e={$_.Stats.DataSize}}, ` 
    @{n='BackupSize';e={$_.Stats.BackupSize}} | Export-Csv -Path 'C:\report.csv' -append
  }
} 
I would like to add these columns:
Computer Name, Vm Name, Provisonned Size.

I run the script in the powershell of a Veeam server which groups the backups of several DAAS clients.

Thank you.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: CSV report

Post by oleg.feoktistov »

Hi,

Am I correct to assume that with Computer Name and VM Name properties you are intended to differentiate if a backup was made for vm or agent?

Thanks,
Oleg
sebastien MULOT
Novice
Posts: 7
Liked: never
Joined: Nov 15, 2021 10:31 am
Contact:

Re: CSV report

Post by sebastien MULOT »

Hello Oleg,

I want to have the name of the vm and the computer to automatically integrate into an internal developed computer park management software in the company where I work, the size of the vhdx of the vm and all of the space occupied by the backcup of this vm to do the customer invoicing in a precise way.
In our management software we recognize the vm by their name and by the computer name, with the script I found I get the name of the backup and the developer cannot use it.

Thank you for the help you can give me.

Sorry for the bad english i use Google translate to help me.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: CSV report

Post by oleg.feoktistov »

I still don't understand how you intend to differentiate vm name and computer name. In our Powershell module vm name you see in a restore point or a storage equals to computer name (if talking about a vm as of a computer). If you mean the other case, like, machines backed up with agent backup job, please let me know.

Now, about other properties. You can get VM Name slightly adjusting your script to get restore points first:

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $rps = Get-VBRRestorePoint -Backup $backup
  foreach ($rp in $rps) {
  $storage = $rp.GetStorage()
  $storage | select @{n='Name';e={$_.PartialPath}}, @{n='VmName';e={$rp.VmName}}, @{n='DataSize';e={$_.Stats.DataSize}}, ` 
    @{n='BackupSize';e={$_.Stats.BackupSize}} | Export-Csv -Path 'C:\report.csv' -append
  }
} 
As for ProvisionedSize, if you mean the size of an original vm, you would need to match object in a restore point with an infrastructure object and then get ProvisionedSize from that infrastructure object:

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $rps = Get-VBRRestorePoint -Backup $backup
  foreach ($rp in $rps) {
  $storage = $rp.GetStorage()
  $object = $rp.GetObject()
  $vm = Find-VBRViEntity -VMsAndTemplates | where {$_.Reference -eq $object.ObjectRef}
  $storage | select @{n='Name';e={$_.PartialPath}}, @{n='VmName';e={$rp.VmName}}, @{n='DataSize';e={$_.Stats.DataSize}}, ` 
    @{n='BackupSize';e={$_.Stats.BackupSize}}, @{n='ProvisionedSize';e={$vm.ProvisionedSize}} | Export-Csv -Path 'C:\report.csv' -append
  }
} 
The trick with ProvisionedSize works with VMware vms only though.

Best regards,
Oleg
sebastien MULOT
Novice
Posts: 7
Liked: never
Joined: Nov 15, 2021 10:31 am
Contact:

Re: CSV report

Post by sebastien MULOT »

Hello Oleg,

It works perfectly, thank you very much.

Best regards,

Sébastien
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests