VMware Cloud Community
PatchAddams
Contributor
Contributor
Jump to solution

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?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
bshubinsky
Hot Shot
Hot Shot
Jump to solution

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)?

Reply
0 Kudos
PatchAddams
Contributor
Contributor
Jump to solution

Thanks for your reply, but this book discusses the Service Console commands, and not the PowerShell / VIClient commands.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
PatchAddams
Contributor
Contributor
Jump to solution

Thanks for your answer. That was exactly what I was looking for! Much appreciated.

Reply
0 Kudos
amanvcp
Contributor
Contributor
Jump to solution

LucD,

Can you help me get MPP info with this script.

Thanks.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos