VMware {code} Community
numulite
Enthusiast
Enthusiast

How to increase speed get-vm get-view

Hi,

I'm new in PowerCLI.

I'm using next script to obtain Virtual Machine Inventory:

$outputFileVM = 'D:\PowerShell_scripts\Inventory.csv'
$VMReport = @()
get-vm | sort name | %{
$VM = Get-View $_.ID
$row = "" | Select-Object VM_Name, VM_Host, VM_Host_Model, VM_Memory, VM_vCpu, VM_CpuLimit, VM_CpuShares
$row.VM_Name = $VM.Config.Name
$row.VM_Host = Get-VMHost -VM $_
$row.VM_Host_Model = Get-VMHost -VM $_ | Get-View | % {$_.Hardware.SystemInfo.Model}
$row.VM_Memory = $VM.Config.Hardware.memoryMB
$row.VM_vCpu = $VM.Config.Hardware.numCPU
$row.VM_CpuLimit = $VM.Config.CpuAllocation.Limit
$row.VM_CpuShares = $VM.Config.CpuAllocation.Shares.Shares
$VMReport += $row
}
$VMReport | Export-Csv $outputFileVM -NoTypeInformation

This script runs very slow. I read something about how to increase speed using get-view -viewType. But I don't know how to use it to refactory in this script.

Anyone can help me?

Thanks.

Eduard.

0 Kudos
1 Reply
lamw
Community Manager
Community Manager

You might want to post your inquiry on the PowerCLI forums: http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli

This is the just the sample code repo, not sure how many monitor this forum. There are some great gurus on the PowerCLI forum that should be able help answer your question

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".