VMware Cloud Community
EdZ
Contributor
Contributor
Jump to solution

Possible to query Extent details on datastore from PowerCLI?

Hello,

Using the vSphere client, there is a way to view the properties of a datastore (under Configuration tab, Storage) where it shows the Extent information which includes the UUID information on the LUN. Is there a way to view the same information in PowerCLI? Here's what I'm trying to do - given a datastore, I would like to identify the storage device which is holding it, preferably using something unique like the UUID. In the case of EMC devices at least, it contains the WWN for the device, so we can match up this with the storage information visible from the SAN. I've browsed the objects within get-datastore | get-view, but none of them seem to expose this.

Thanks,

Ed

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Hi Ed,

Get-Datastore <Datastorename> | Get-Scsilun

gives you the extent in the CanonicalName property.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

Reply
0 Kudos
10 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Hi Ed,

Get-Datastore <Datastorename> | Get-Scsilun

gives you the extent in the CanonicalName property.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
EdZ
Contributor
Contributor
Jump to solution

So simple - works perfectly

Thanks!

Ed

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try this, it will give you the datastorename and the extent.

$report = @()

Get-Datastore <datastorename> | Get-View | %{
	$ds = $_
	$esx = Get-View $ds.Host[0].Key
	$ds.Info.Vmfs.Extent | %{
		$ext = $_
		$extKey = ($esx.Config.StorageDevice.ScsiLun | where {$_.CanonicalName -eq $ext.DiskName}).Key
		$lun = $esx.Config.StorageDevice.MultipathInfo.Lun | where {$_.Lun -eq $extKey}

		$row = "" | Select ESXname, DSname, Extent, Partition, "Path Selection","Paths Total"
		$row.ESXname = $esx.Name
		$row.DSname = $ds.Name
		$row.Extent = $ext.DiskName
		$row.Partition = $ext.Partition
		$row."Path Selection" = &{
			switch($lun.Policy.Policy){
				"VMW_PSP_FIXED"{"Fixed"}
				"VMW_PSP_RR"{"Round Robin"}
				"VMW_PSP_MRU"{"Most Recently Used"}
			}
		} 
		$row."Paths Total" = $lun.Path.Count
		$report += $row
	}
}
$report

And this will work with PowerCLI 4 as well.

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
kevinjj
Contributor
Contributor
Jump to solution

Hi Luc,

It's unable to get DSName on PowerCLI 4.1 U1 build 332441.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Hi Kevin,

Just ran it with PowerCLI 4.1 U1 and I see the datastore names in the report.

Do you get any error messages ?


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

Reply
0 Kudos
kevinjj
Contributor
Contributor
Jump to solution

unfortunately no errors. Is it for ESX version 4.0 and above?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, it's for ESX 4.x


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

Reply
0 Kudos
kevinjj
Contributor
Contributor
Jump to solution

Is it possible get a version for ESX 3.x?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid I don't have any ESX 3.x servers left, so it will be difficult to create a script 😞


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

Reply
0 Kudos
system_noida
Enthusiast
Enthusiast
Jump to solution

Hi Luc,

will this works for Esxi and vcenter server 6.7 ?

And also I want to input a csv file with some Datastore Name to find the extent only for selected Datastore , could you please help me how I can add that in below script.

Reply
0 Kudos