VMware Cloud Community
jmedd
Enthusiast
Enthusiast
Jump to solution

Find device property of a datastore

In the VI client when you view storage information you see the Identification of the datastore and in the next column Device.

This Device property is not available when you use Get-Datastore, is there a way to dig a bit deeper and find it? I need to list out all my datastores and the information in that device column.

Thanks

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Have a look at the script I gave in .

If you only want the DS name and the Device you can use the condensed version below.

function Get-DSDevice($dsImpl)
{
		$ds = Get-View -Id $dsImpl.Id
		$esx = Get-View $ds.Host[0].Key
		$hss = Get-View $esx.ConfigManager.StorageSystem

		foreach($mount in $hss.FileSystemVolumeInfo.MountInfo){
		    if($mount.volume.name -eq $ds.Info.Name){
			switch($mount.Volume.Type){
			"VMFS" {
				foreach($ext in $mount.Volume.Extent){
					if($mount.volume.name -eq $ds.Info.Name){
						$device =$ext.DiskName + ":" + $ext.Partition
					}
				}
			  }
			"NFS" {
			    $device = $mount.Volume.RemoteHost + ":" + $mount.Volume.RemotePath
			  }
			}
		  }
		}
	$device
}

$report = @()
Get-Datastore | %{
	$row = "" | Select dsName, dsDevice
	$row.dsName = $_.Name
	$row.dsDevice = Get-DSDevice $_
	$report += $row
}
$report


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at the script I gave in .

If you only want the DS name and the Device you can use the condensed version below.

function Get-DSDevice($dsImpl)
{
		$ds = Get-View -Id $dsImpl.Id
		$esx = Get-View $ds.Host[0].Key
		$hss = Get-View $esx.ConfigManager.StorageSystem

		foreach($mount in $hss.FileSystemVolumeInfo.MountInfo){
		    if($mount.volume.name -eq $ds.Info.Name){
			switch($mount.Volume.Type){
			"VMFS" {
				foreach($ext in $mount.Volume.Extent){
					if($mount.volume.name -eq $ds.Info.Name){
						$device =$ext.DiskName + ":" + $ext.Partition
					}
				}
			  }
			"NFS" {
			    $device = $mount.Volume.RemoteHost + ":" + $mount.Volume.RemotePath
			  }
			}
		  }
		}
	$device
}

$report = @()
Get-Datastore | %{
	$row = "" | Select dsName, dsDevice
	$row.dsName = $_.Name
	$row.dsDevice = Get-DSDevice $_
	$report += $row
}
$report


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

0 Kudos
jmedd
Enthusiast
Enthusiast
Jump to solution

Brillant, thanks for the quick response.

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
0 Kudos