Detail Report about all VMs - Performance Issue

PowerShell script exchange

Detail Report about all VMs - Performance Issue

Veeam Logoby Talom » Wed Apr 26, 2017 1:18 pm 1 person likes this post

Hey,
i wrote this script a few years ago and it worked fine. But if you execute this script against a bigger Veeam server with about 1000 VMs or more it takes longer than 2 or 3 hours.
I know "Find-VBRObject" is deprecated but i like the informations about RAM, Connection State, Power State etc. which i don't receive if i am using" Find-VBRViEntity".

Does anyone know, how i can get the same information faster?

Code: Select all
try {
    write-host "Starting Veeam Query for DOC"
    Add-PSSnapin -Name VeeamPSSnapIn #-ErrorAction SilentlyContinue
    write-host "Veeam snapin added"
   
    ###############################################################################
    # CSV-Targetfile
    ###############################################################################
   if (!$args[0]) {
        write-host "CSV target file expected"
        exit 4
    }
    $csvFile = $args[0]
   
    write-host "Write data to file $csvFile"
   
   
    ###############################################################################
    # Query VMs and write to CSV
    ###############################################################################

    $list = @()
    $vmobjs = Get-VBRServer | Where-Object { $_.Type -eq "ESXi" } | Find-VBRObject | Where-Object {$_.Type -eq "VirtualMachine"}
    $list += $vmobjs


   $list = $list| select -uniq
   
   foreach ($node in $list) {
        $dcName = $node.FindParent("Datacenter").Name
        $node | Add-Member -MemberType NoteProperty -Name "DataCenterName" -Value $dcName
       $node | Add-Member -MemberType NoteProperty -Name "HostName" -Value $node.Host.Name -Force
   }
   

   $list | Select-Object Name, PowerState, Uuid, ResourcePool, VmFolder, VmFolderName, IsTemplate, ConnectionState, ChangeTracking, FaultTolerance,ConfigVersion,MemoryInMB,CurrentSnapshotRef,Capacity,RealVmSize,RootSnapshot,Type,Ref,Id,Path,Parent, AnnotationNotes, HostName, DataCenterName | Export-Csv $csvFile -NoTypeInformation -Encoding UTF8

}
catch [System.Exception] {
    write-output $_
    write-output "Error running script"
    exit 8
}
exit 0
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Detail Report about all VMs - Performance Issue

Veeam Logoby tsightler » Wed Apr 26, 2017 4:45 pm

A you note, Find-VBRObject is deprecated, and what this means is that it shouldn't be used any more and it doesn't receive much (any?) testing. It's actually pretty broken at this point (it was always somewhat broken), for example, every run just returns every object, regardless if you tell it a specific server or not so in a large environment your current code will end up with 10's of thousands of objects (or more) in $list and will be time consuming. Even in my lab with 10 hosts it contains almost 1400 objects!

Since your report doesn't appear to have anything VMware specific in it, you might consider just using VMware vPower CLI instead.

As an absolute hack, you could probably just change the following line:
Code: Select all
$vmobjs = Get-VBRServer | Where-Object { $_.Type -eq "ESXi" } | Find-VBRObject | Where-Object {$_.Type -eq "VirtualMachine"}

to
Code: Select all
$vmobjs = Find-VBRObject | Where-Object {$_.Type -eq "VirtualMachine"}


So you only call Find-VBRObject once for the entire environment instead of once for each ESXi host.
tsightler
Veeam Software
 
Posts: 4872
Liked: 1821 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Detail Report about all VMs - Performance Issue

Veeam Logoby Talom » Thu Apr 27, 2017 2:24 pm

I am not sure, if i can use vPower CLI on all Veeam Servers, but i will check that. Maybe it's my only chance.

Unfortunately it's not possible to execute your code, because of a missing parameter (Server).
As i remember my tests in the past, the runtime of the Cmdlet with all servers returns more results than an execution with one server, even after i made it unique. (Some replicas were missed...)
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Detail Report about all VMs - Performance Issue

Veeam Logoby tsightler » Thu Apr 27, 2017 8:25 pm

For me, Find-VBRObject resturns the exact same 226 objects in my lab no matter what server I specify, I can choose any ESXi host, or the vCenter, it's always the same 226 objects. I'm sure it didn't work this way in the past, I think it's just that this command isn't very functional in recent versions because it's deprecated and not being updated anymore to keep up with internal code changes.
tsightler
Veeam Software
 
Posts: 4872
Liked: 1821 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Detail Report about all VMs - Performance Issue

Veeam Logoby albertwt » Thu May 18, 2017 1:03 pm

Is there any update on this script for Veeam Backup v9.5 ?
--
/* Veeam software enthusiast user & supporter ! */
albertwt
Expert
 
Posts: 621
Liked: 20 times
Joined: Thu Nov 05, 2009 12:24 pm
Location: Sydney, NSW

Re: Detail Report about all VMs - Performance Issue

Veeam Logoby v.Eremin » Wed May 31, 2017 9:18 am

Have you tried to run it against 9.5 environment? Based on the previous responses and post time, it should work fine with VB&R 9.5. Thanks.
v.Eremin
Veeam Software
 
Posts: 13709
Liked: 1026 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 1 guest