VMware Cloud Community
OpcoPaul
Contributor
Contributor
Jump to solution

VM to Cluster script

Hello all,  I'm looking to get a script that will allow me to input a list of VM's that will tell me which Cluster they belong to as well as Virtual Hardware information (CPU, Mem, Disk, Etc.)

Any help would be appreciated!!!

Thanks, Paul

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean like this ?

$vmName = Read-Host -Prompt "Enter a VM name"

Get-VM -Name $vmName | Select Name,@{N='Cluster';E={(Get-Cluster -VM $_).Name}},NumCpu,MemoryGB

Or this ?

$vmNames = Get-Content vmnames.txt

Get-VM -Name $vmNames | Select Name,@{N='Cluster';E={(Get-Cluster -VM $_).Name}},NumCpu,MemoryGB


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this (I only show a limited number of properties that are available on the VirtualMachine object.

Get-VM | Select Name,@{N='Cluster';E={(Get-Cluster -VM $_).Name}},NumCpu,MemoryGB


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
OpcoPaul
Contributor
Contributor
Jump to solution

Thanks but I was looking for a script that I can input my own VM's and get the Cluster info.  Any ideas?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You mean like this ?

$vmName = Read-Host -Prompt "Enter a VM name"

Get-VM -Name $vmName | Select Name,@{N='Cluster';E={(Get-Cluster -VM $_).Name}},NumCpu,MemoryGB

Or this ?

$vmNames = Get-Content vmnames.txt

Get-VM -Name $vmNames | Select Name,@{N='Cluster';E={(Get-Cluster -VM $_).Name}},NumCpu,MemoryGB


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
OpcoPaul
Contributor
Contributor
Jump to solution

That works perfectly!  Thanks so much!

0 Kudos