Hi Experts ,
Need your advices on this genuine problem we are facing in our Virtual Infrastructure.
We have nearly 3000 VMs deployed in our infra and it started growing at a rapid pace than we thought. We have some
series/nodes of VMs which we don't want to locate on same ESXi hosts because of single point of failure.This was a blunder from our side we forgot to set affinity/antiaffinity rules for those VMs during the deployment time.Now we want to identify those VMs which exists in the same ESXi hosts.
For example :
test-vm-tomcat-1
test-vm-tomcat-2
both are located in the same esxi host (esxi-test-1).So we want to move test-vm-tomcat-2 to another esxi host. Will it be possible to sort it or filter it through Powercli Scripts.I just want to identify the VMs (test-vm-tomcat*) location through scripts.
Any suggestions/advices are much appreciated.
Thanks in Advance.
Regards,
sg
You are asking for a script, but from what you want I understand that you want to achieve, so you may optionally want take a look at RVTools which allows you to export all information to Excel, where you can sort the data as you like/need it.
André
If it is just the location of the VMs you want, you can do
Get-vm -Name "test-vm-tomcat" | Select Name,Host
From here you could also automate the creation of anti-affinity rules or move the VMs to other ESXi nodes.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot guys for your suggestions.
I used the below syntax and exported them in csv format & used custom sort to get the VM names sorted in alphabetical/numerical order.
Get-VM | Select Name, @{N="ESX Host";E={Get-VMHost -VM $_}}|Export-Csv
One query how do i make sure that two VMs nodes must not migrated to the same ESXi servers by DRS/HA.
Regards,
sg
You use anti-affinity rules.
See the DRSRule – a DRS rules and groups module post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference