PowerCLI script to list VMFS,RDM and Free LUNs in a cluster

Its always a time consuming job to find out the LUN is FREE, RDM or VMFS. The following script will help to get the details of LUNs from hosts in a cluster and will tell us the LUN is VMFS, RDM or FREE.

If the LUN is an RDM, we can see on which VM RDM is mapped. And if the LUN has VMFS volume, the datastore name will be displayed. Also the script provides the details like LUN number, Capacity and naa id (Canonical Name).

The CSV file that is produced by the script looks like this. In this example cluster has four hosts (esx1,esx2,esx3 and esx4), four LUNs (0,1,2 and 13) are shared among them.


You can see there are four values for TYPE.

1. VMFS :- VMFS volume (datastore)

2. RDM :- Raw Device Map(RDM) LUN connected to a VM. We can see the corresponding VM in VMname column.
3. FREE :- The LUNs which are free for creating VMFS Datastores or RDMs.
4. UNKNOWN :- On two cases UNKNOWN will be shown.
a.  the LUNs which are presented as RDM on other host. In the example, LUN 13 is an RDM on virtual machine “TestVM1” running on host “esx1”. Hence LUN 13 will shown as UNKNOWN on other hosts in the cluster.
b. Script couldn’t find whether the LUN is VMFS, RDM or Free.