PowerCLI Script to get a list of VMs spec

One of my friend had a requirement that he needs to get a list of VMs spec for per VM each vCPU, vRAM and vDisks configured size. The list of VMs is more about 150 VMs running on a vCenter which is hosted thousands of VMs.

It will be a wasting of time taking the spec manually. So this piece of code will do the work in a minute. 

Add this code in to a text file and save it as a name.ps1 file. Also create a vm_list.txt file and add the list of VMs to it. Save 2 files in the same location then open the PowerCLI and run the name.ps1 script.

The script output file will save as a csv format in the same file path.

connect-viserver “vcenter FQDN / IP” -user “[email protected]” -password “Password”

$vms = Get-Content “C:\Path_to_folder\vm_list.txt”

$output = foreach ($vm in $vms) {
Get-VM $vm | Select Name, NumCPU, MemoryGB, ProvisionedSpaceGB
}
$output | Export-Csv -Path C:\Path_to_folder\vmspec.csv -NoTypeInformation

 

Hope this will help for some one. 😉

 

 

Rating: 3.3/5. From 5 votes.
Please wait...

You may also like...

1 Response

  1. Pubudu says:

    Awesome. Thanks a lot. saved my day

Leave a Reply

Your email address will not be published. Required fields are marked *

PowerCLI Script to get a list of VMs spec

time to read: <1 min
1