Locate vms that are in particular cluster and are using particular datastore in powercli

A quick one :
Trying to find which vms are residing on datastore :”datastore_name” and are located in cluster “your_cluster”

Get-Cluster "your_cluster"|Get-vm |?{($_.extensiondata.config.datastoreurl|%{$_.name}) -contains "datastore_name"}
or
Get-Cluster "your_cluster"|Get-vm |?{($_.extensiondata.config.datastoreurl|?{$_.name -eq "datastore_name"})}

It’s easier if the vms reside on particular datastore and you do not care in which cluster they are:

(Get-Datastore -Name 'datastore_name').Extensiondata.Vm|%{(Get-View -Id $_.toString()).name}

And approach where you want to check all datastores in specific cluster:
So i was thinking about this and came out with that 😉 :

get-vmhost -Location "Cluster_01"|get-datastore|%{$ds=$_; $ds.Extensiondata.Vm|%{$_|select @{n='vm name';e={(Get-View -property name -Id $_.toString()).name}},@{n='ds name';e={$ds.name}}  }}

In case you want to check serveral datastores with known names for vms you can do this, assuming that for example names are written in file : c:\dsfile.txt

Get-Datastore -Name (get-content c:\dsfile.txt) | %{$temp=$_; $temp.extensiondata.vm | % { $_ | select @{n='VMName';e={(get-view -property name -id $_).Name}},@{n='ds';e={$temp.name}}}}
Advertisements

Summary tab error message about datastores hearbeat

In the esxi host i received a message:

The number of heartbeat datastores for host is 1, which is less than required: 2

In my case i had only 1 datastore, and i did not want to see this message so in order to get rid of that i used this kb:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006421

So basically, go to cluster HA settings, and click HA advanced settings button.

Add new advanced property:

das.ignoreinsufficienthbdatastore  with value set to true

Unmount nfs datastore error

When umouting nfs datastore which was not holding any powered vm we received error that this operation can’t be completed. I checked logs, nothing interesting in there. Tried couple workarounds, still nothing.

Apparently what we had to do in order to unmount nfs store is to unregister the vm templates from the datastore…

I hope that will save you a lot of time.