We have a large grouping of VM's that are not always required to be running and would like to find a way to shutdown these particular VM's on a sunday night.
Now anyone know how to find a group of VM's (either via label, project, category etc) and pass a shutdown command. Ideally I would like to do this via PowerShell but I will take anything.
Best answer by devwanglerView original
To shutdown a VM you have multiple options as well:
So all you would have to do was loop thru the above with the filtered computer list.
I'm looking for something in AHV. That way the grouping can be dynamic and we don't have to maintain a listing of VM's that I would have to iterate through.
I have found that in Prism we can group machines with Categories. We can interrogate the categories via REST API and then shut them down... I just now need to learn about REST API's and how to interrogate them 🙂
to get the raw list of VMs and then pipe the results thru a filtered grep then pipe the results of that to the LINUX command above?
Let us know how you make out.
Created a category in Prism, assigned all the VM's that I want to shutdown to the category.
Then I wrote the script below which queries the category via REST API into a hash table. Then using the Nutanix PS cmdlets, I iterate the hash table and power down the VM's.
It now runs via a scheduled task once a week, powering down all non-essential VM's.
I know it relates to restoring the VMs in a PD but the code has some omph.
Thank you for sharing this with the Community.