VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso

PowerCLI to show Which VMFS data store is on VMFS-3 ?

Hi All,

Can anyone here please share some script to show which VMFS data store is currently on VMFS3 and its NAA ID ?

Thanks in advance.

/* Please feel free to provide any comments or input you may have. */
5 Replies
rcporto
Leadership
Leadership

Using RVTools, just check the vDatastore tab. But, if you really want a script, take a look here: » How to detect VMFS3 and VMFS3 Upgraded Datastores with PowerCLI; Now with more sugar!

---

Richardson Porto
Senior Infrastructure Specialist
LinkedIn: http://linkedin.com/in/richardsonporto
AlbertWT
Virtuoso
Virtuoso

rcporto‌, thanks for the reply.

The script below, I need to view the VMFS Datastore display name:

foreach ($myHost in Get-VMHost)

#This tells the system to do a run the command against all "VMHosts" that you have defined as part of your Connect-VIServer

{

    Write-Host ‘$myHost = ‘ $myHost

    #Display the ESXi Host that it is operating against, helps if you’re scanning multiple vCenters

    $esxcli = Get-EsxCli -VMHost $myHost

    #This sets the syntax and the context for the Get-EsxCli command to operate, a requirement for running $esxcli.Commands

    $esxcli.storage.core.device.partition.list() |

    #Use Get-EsxCli to list the core storage devices

    Where {$_.StartSector -eq "128"} |

    #This specifies we’re only looking for partitions which have a StartSector of 128, which could mean either VMFS3 or VMFS3 upgraded to VMFS5 Datastores

    Select Device, StartSector

}

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership

Try something like this.

This will work for VMFS datastores, if you have NFS datastore, the script will need to be adapted (but then you wouldn't have NAA values in any case).

Get-Datastore | where{$_.FileSystemVersion -match "^3."} |

select Name,FileSystemVersion,@{n='NAA';E={$_.ExtensionData.Info.Vmfs.Extent[0].DiskName}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AlbertWT
Virtuoso
Virtuoso

LucD‌, thanks for the reply.

Somehow the script only returns the VMFS data store that is specifically on version 3.0

So is it possible to modify the script to view which VMFS datastore that has been upgraded from 3.0 to 5.58 ?
the script i pasted before was OK, but it only shows the NAA.id not the VMFS datastore name.

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership

Try like this

    foreach ($myHost in Get-VMHost)  

    #This tells the system to do a run the command against all "VMHosts" that you have defined as part of your Connect-VIServer  

    {  

        Write-Host ‘$myHost = ‘ $myHost  

        #Display the ESXi Host that it is operating against, helps if you’re scanning multiple vCenters  

        $esxcli = Get-EsxCli -VMHost $myHost  

        #This sets the syntax and the context for the Get-EsxCli command to operate, a requirement for running $esxcli.Commands  

        $esxcli.storage.core.device.partition.list() |  

        #Use Get-EsxCli to list the core storage devices  

        Where {$_.StartSector -eq "128"} |  

        #This specifies we’re only looking for partitions which have a StartSector of 128, which could mean either VMFS3 or VMFS3 upgraded to VMFS5 Datastores  

        Select Device, StartSector,@{N='DS';E={$lun = $_; $esxcli.storage.vmfs.extent.list() | where{$_.DeviceName -eq $lun.Device} | select -ExpandProperty VolumeName}}  

    }  


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos