Nutanix : Get List of Powered-off VMs (AHV)


We have a quite large AHV infrastructure and sometimes this is not always easy to get all the relevant details to improve/maintain it. Don't get me wrong, Prism Central is helping a lot. But, when it comes to optimisation of the assets, it is hard to see what gains we can make - starting by detecting the powered off VMs.

Powered-Off VMs

VMs that are powered off are not taking any compute : True ! But what about storage ? Everything is thin provisioning by default on Nutanix, this is correct, but when you have many VMs powered off without any relationship between them, you still have some storage and reserved storage allocated. This is not always very obvious in Prism Central and I did not find a way to report the consumed storage.

There is a Prism Central API endpoint that help achieving this goal.


This call requires a payload to be sent, this payload is actually a way to filter the results. Remember, we need to get the powered off VM. So, we filter on the power_state.

"kind": "vm",
"filter": "power_state == off",
"length" : 500

The parameter length is specifying the maximum number of rows to return.
In a cURL statement, you get something similar to this : 

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{ \"kind\": \"vm\", \"filter\": \"power_state == off\", \"length\" : 500 }" ""

The result is a long list of JSON-like string where it is easy to find the relevant information about the VMs and their status.

Of course, this could be interfaced into a script It can be find here. Please note the new function added to my Nutanix php Framework : nxpcGetOffVMs($clusterConnect).

Here is a sample output :

Sorry for the blurred area, I just need to protect my asset (even if they are powered off by now ;)

So, according to the above screenshot, we could reclaim almost 3 TB if we remove them. This is some serious savings ! Pay attention, this figure could be over estimated if your VM disks are not completely used and if you have linked clones ...

Disclaimer : this script only supports AHV with the current Prism Central version (2021.9.0.1). There are plans to get support for vmware as well in a future release. If your plan is to get any type of VMs, you need to query each clusters separately for each types of VMs family. This could be a nice evolution for this script.

I encourage you to run this tool regularly to make sure there are no VMs out of sights. This is not a bad thing to have powered off VMs on your clusters, forgetting them could be an issue, especially if you are short on storage.

I hope this helps !


What's hot ?

Nutanix AHV : Running Windows 11 beta

Nutanix : Create a simple VM with Terraform