PowerShell script exchange
Post Reply
Andr2210
Novice
Posts: 5
Liked: never
Joined: Nov 28, 2023 11:19 am
Full Name: Andr2210
Contact:

Which virtual machines are located on which virtualization node?

Post by Andr2210 »

hi!
Is it possible to use PowerShell cmdlets to find out from the backup task which virtual machines are on which virtualization host?
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Which virtual machines are located on which virtualization node?

Post by oleg.feoktistov »

Hi,

Not directly from task session object, so you'd have to query infrastructure to see where a vm resides. Example for VMware:

Code: Select all

$sessions = Get-VBRBackupSession
$vms = Find-VBRViEntity -VMsAndTemplates
foreach ($session in $sessions) {
   if ($session.Platform.ToString() -eq "EVMware") {
   $taskSessions = Get-VBRTaskSession -Session $session
   foreach ($taskSession in $taskSessions) {
     $vm = $vms | where {$_.Name -eq "$($taskSession.Name)"}
     $vm | select Name, VMHostName
    }
   }
}
Best regards,
Oleg
Andr2210
Novice
Posts: 5
Liked: never
Joined: Nov 28, 2023 11:19 am
Full Name: Andr2210
Contact:

Re: Which virtual machines are located on which virtualization node?

Post by Andr2210 »

Hi! Привет!
Get-VBRBackupSession Returns tasks performed during job sessions.

but at the time of launching the script, it may not be executed. I have your script hanging on the first line in a long wait. maybe the first line should have Get-VBRTaskSession ?

Во время запуска скрипта он не выполняется. У меня скрипт висит на первой строке в долгом ожидании. Возможно, в первой строке должно быть Get-VBRTaskSession ?
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Which virtual machines are located on which virtualization node?

Post by david.domask »

Hi @@Andr2210,

Get-VBRBackupSession will retrieve all sessions, so that's likely why it's taking awhile.

Does this data need to come from the task sessions? COib objects returned by Get-VBRRestorePoint have this data also and it should be a faster call:

$job = Get-VBRJob -name 'name of job'
$backups = Get-VBRBackup -name $job.name
$RPs = Get-VBRRestorePoint -Backup $backups

PS C:\Users\Administrator> $RPs | Select VMName, @{n="ESXi Host";e={$_.Auxdata.esxname}}

VmName ESXi Host
------ ---------
ddom-tinyvm someesxihost.local
ddom-tinyvm someesxihost.local
ddom-tinyvm someesxihost.local
ddom-tinyvm someesxihost.local

Will it work for you to pull this information from the COib objects or it must be from Session data?
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests