I'm in need of a powercli script to get the ESXi host model, CPU, Memory, CPU model. I've about 300 VMs in my list and those are in different vCenters.
Would like to input them in a file and then script should be able to provide the above asked information.
Script should be able to check, currently on which ESXi host each VM residing on and get the ESXi host list and its required information (in a tabular format) like below:
VM name, ESXi host name, Host Model, CPU, Memory, ESXi host CPU model
can some one help here please. TIA
get-VM | Select Name,
@{N="Host";E={$_ | Get-VMhost | select -ExpandProperty Name}},
@{N="Model";E={$_ | Get-VMhost | select -ExpandProperty Model}},
@{N="CPU";E={$_ | Get-VMhost | select -ExpandProperty ProcessorType}},
@{N="NumCPU";E={$_ | Get-VMhost | select -ExpandProperty NumCpu}},
@{N="MemGB";E={$_ | Get-VMhost| select -ExpandProperty MemoryTotalGB}} | FT
thanks, does it take the VM names from a file ?
$vmList = Get-Content C:\temp\inputFile.txt
get-VM $vmName | Select Name,
@{N="Host";E={$_ | Get-VMhost | select -ExpandProperty Name}},
@{N="Model";E={$_ | Get-VMhost | select -ExpandProperty Model}},
@{N="CPU";E={$_ | Get-VMhost | select -ExpandProperty ProcessorType}},
@{N="NumCPU";E={$_ | Get-VMhost | select -ExpandProperty NumCpu}},
@{N="MemGB";E={$_ | Get-VMhost| select -ExpandProperty MemoryTotalGB}} | FT
get-vm accepts an array of one or more names
As an alternative, and without the many calls to Get-VMHost, you could do
Select Name,
@{N="VMHost";E={$_.VMhost.Name}},
@{N="Model";E={$_.VMhost.Model}},
@{N="CPU";E={$_.VMhost.ProcessorType}},
@{N="NumCPU";E={$_.VMhost.NumCpu}},
@{N="MemGB";E={$_.VMhost.MemoryTotalGB}} |
Format-Table -AutoSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference