Skip navigation
VMware

This Question is Answered (go to answer)

2 "helpful" answers available (6 pts)
777 Views 6 Replies Last post: May 23, 2012 10:48 PM by LucD RSS
PatchAddams Novice 11 posts since
Jun 10, 2008
Currently Being Moderated

Aug 17, 2010 7:13 AM

List VMFS version and blocksize of all Datastores

I am searching for a PowerShell script (or preferably one-liner) to list all datastores with there VMFS version number and their blocksizes.

 

I'm a PowerShell and ViToolkit novice, but I know how to do the following:

 

I can list all datastores that start with a specific name and sort them alphabetically :

Get-Datastore -name eva* | sort

 

Name                        FreeSpaceMB      CapacityMB

 

EVA01VMFS01             81552              511744

EVA01VMFS02            511178             511744

EVA01VMFS03            155143             511744

EVA01VMFS04              76301             511744

EVA01VMFS05            301781             511744

etc...

 

I can get info for a specific datastore with the following commands:

 

$objDataStore = Get-Datastore -name "EVA01VMFS01"

 

$objDataStore | Format-List

 

DatacenterId : Datacenter-datacenter-21

ParentFolderId : Folder-group-s24

DatastoreBrowserPath : vmstores:\vCenter-test.local@443\DataCenter\EVA01VMFS01

FreeSpaceMB : 81552

CapacityMB : 511744

Accessible : True

Type : VMFS

Id : Datastore-datastore-330

Name : EVA01VMFS01

 

But that's about as far as my knowledge goes.

Anyone out there that could help me out with this one?

bshubinsky Hot Shot 191 posts since
May 5, 2009
Currently Being Moderated
1. Aug 17, 2010 7:22 AM in response to: PatchAddams
Re: List VMFS version and blocksize of all Datastores

I'm a CLI noob but have you checked the CLI Installation and Reference Guide (http://www.vmware.com/pdf/vsphere4/r40/vsp_40_vcli.pdf)?

LucD Guru User Moderators vExpert 9,015 posts since
Oct 31, 2005
Currently Being Moderated
3. Aug 17, 2010 8:33 AM in response to: PatchAddams
Re: List VMFS version and blocksize of all Datastores

That information is not available in the default properties of the DatastoreImpl object.

But that information is available in the SDK object called Datastore.

You can display these values like this.


Get-Datastore | Get-View | Select-Object Name, 
                                    @{N="VMFS version";E={$_.Info.Vmfs.Version}},
                                    @{N="BlocksizeMB";E={$_.Info.Vmfs.BlockSizeMB}}

 

If you are using PowerCLI 4.1, you can check with


Get-PowerCLIVersion

 

then you can use the New-VIProperty cmdlet.

Something like this


New-VIProperty -Name VMFSVersion -ObjectType Datastore `
     -Value {
          param($ds)

          $ds.ExtensionData.Info.Vmfs.Version
     } `
     -BasedONextensionProperty 'Info' `
     -Force

New-VIProperty -Name VMFSBlockSizeMB -ObjectType Datastore `
     -Value {
          param($ds)

          $ds.ExtensionData.Info.Vmfs.BlockSizeMB
     } `
     -BasedONextensionProperty 'Info' `
     -Force

Get-Datastore | Select Name,VMFSVersion,VMFSBlockSizeMB

 

 

 

____________

Blog: LucD notes

Twitter: lucd22

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
amanvcp Lurker 5 posts since
May 17, 2012
Currently Being Moderated
5. May 23, 2012 9:25 PM in response to: LucD
Re: List VMFS version and blocksize of all Datastores

LucD,

Can you help me get MPP info with this script.

 

 

Thanks.

LucD Guru User Moderators vExpert 9,015 posts since
Oct 31, 2005
Currently Being Moderated
6. May 23, 2012 10:48 PM in response to: amanvcp
Re: List VMFS version and blocksize of all Datastores

This is a quick-and-dirty method

 

Get-Datastore | Select-Object Name, 
  @{N="VMFS version";E={$_.ExtensionData.Info.Vmfs.Version}},
 
@{N="BlocksizeMB";E={$_.ExtensionData.Info.Vmfs.BlockSizeMB}},
  @{N="MPP";E={     $esx = Get-View $_.ExtensionData.Host[0].Key
   
$_.ExtensionData.Info.Vmfs.Extent | %{       Get-ScsiLun -CanonicalName $_.DiskName -VmHost $esx.Name |
     
Select -ExpandProperty MultipathPolicy
    }   }}

 

It assumes that you have a 1:1 datastore-LUN setup, and it only checks the MPP on the first host on which the datastore is defined.

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com

Bookmarked By (0)

Share This Page

Communities