PowerShell script exchange
Post Reply
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

How to get VMName & VBM File with path ?

Post by dsATspace »

Hello,
I like to get the output:

<vmname>,<drive>:\path\to\<vmname>.vbm

for example:

vm1,e:\backups\vm1_job\vm1.vbm
vm2,e:\backups\vm2_job\vm2.vbm

But did did not know how



Tryed with: Get-VBRBackupRepository
but only get e:\backups for example....
and with: Get-VBRBackupFile


VMNames i can get with:

Code: Select all

$jobarray = Get-VBRJob
foreach ($job in $jobarray)
{

$vm=Get-VBRJobObject -Job $job.name
$vm.name

}
thanks to: chris.arceneaux
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to get VMName & VBM File with path ?

Post by david.domask »

Hey dennis,

Use the examples here for how to build the path from backups:

post443044.html#p443044

Note that Scale Out Repos need to be handled differently.
David Domask | Product Management: Principal Analyst
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

Re: How to get VMName & VBM File with path ?

Post by dsATspace »

Hi thanks....

build this one before I saw your post:

Code: Select all

$repo=Get-VBRBackupRepository
$var=$repo.FriendlyPath
Get-ChildItem $var\*.vbm -Recurse |  % { $_.FullName } > c:\scripts\vbm_files.txt


$jobarray = Get-VBRJob
foreach ($job in $jobarray)
{

$vm=Get-VBRJobObject -Job $job.name
$vbmname = Get-Content -Path 'C:\scripts\vbm_files.txt'
$vbmnamenew = $vbmname | select-String $job.name
$vm.name + "," + $vbmnamenew

}
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to get VMName & VBM File with path ?

Post by david.domask »

Your script will work, but you might hit connectivity issues if you have non-local storage (e.g., remote server, linux server, NFS/SMB share, etc)

The Veeam database has all this information, but for Scale out repos it's represented as relative paths, so the real path can be built by hand.

Your code will work, but you will find it does not work for quite a few storage options. If you don't have a complex setup and all local storage, then enjoy! But I strongly advise build it right "the first time" ;) Saves a lot of rewriting later.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests