Hi everyone, I need a powercli script that lists fields below disk naa.id - shows it as RDM or VMFS - Multipath Policy (Fixed or RR) Could anyone help me out? Thanks a lot.
As a variation on my LUN report – datastore, RDM and node visibility post, try like this
$clusName = 'MyCluster'
$scsiTab = @{}
$esxServers | %{
$esxImpl = $_
# Get SCSI LUNs
$esxImpl | Get-ScsiLun -LunType disk} | %{
$key = $esxImpl.Name.Split(".")[0] + "-" + $_.CanonicalName.Split(".")[1]
if(!$scsiTab.ContainsKey($key)){
$scsiTab[$key] = $_.CanonicalName,"",$_.CapacityMB,$_.MultipathPolicy
}
}
# Get the VMFS datastores
$esxImpl | Get-Datastore | where {$_.Type -eq "VMFS"} | Get-View | %{
$dsName = $_.Name
$_.Info.Vmfs.Extent | %{
$key = $esxImpl.Name.Split(".")[0] + "-" + $_.DiskName.Split(".")[1]
$scsiTab[$key][1] = $dsName
}
}
# Get the RDM disks
Get-Cluster $clusName | Get-VM | Get-View | %{
$vm = $_
$vm.Config.Hardware.Device | where {$_.gettype().Name -eq "VirtualDisk"} | %{
if("physicalMode","virtualmode" -contains $_.Backing.CompatibilityMode){
$disk = $_.Backing.LunUuid.Substring(10,32)
$key = (Get-View $vm.Runtime.Host).Name.Split(".")[0] + "-" + $disk
$scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label
}
}
}
$scsiTab.GetEnumerator() | Group-Object -Property {$_.Key.Split("-")[1]} | %{
$lun = New-Object PSObject -Property @{
ClusterName = $clusName
CanonicalName = ''
UsedBy = ''
SizeMB = ''
PathPolicy = ''
}
$_.Group | %{
if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}
if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}
if(!$lun.SizeMB){$lun.SizeMB = $_.Value[2]}
if(!$lun.PathPolicy){$lun.PathPolicy = $_.Value[3]}
}
$lun
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
As a variation on my LUN report – datastore, RDM and node visibility post, try like this
$clusName = 'MyCluster'
$scsiTab = @{}
$esxServers | %{
$esxImpl = $_
# Get SCSI LUNs
$esxImpl | Get-ScsiLun -LunType disk} | %{
$key = $esxImpl.Name.Split(".")[0] + "-" + $_.CanonicalName.Split(".")[1]
if(!$scsiTab.ContainsKey($key)){
$scsiTab[$key] = $_.CanonicalName,"",$_.CapacityMB,$_.MultipathPolicy
}
}
# Get the VMFS datastores
$esxImpl | Get-Datastore | where {$_.Type -eq "VMFS"} | Get-View | %{
$dsName = $_.Name
$_.Info.Vmfs.Extent | %{
$key = $esxImpl.Name.Split(".")[0] + "-" + $_.DiskName.Split(".")[1]
$scsiTab[$key][1] = $dsName
}
}
# Get the RDM disks
Get-Cluster $clusName | Get-VM | Get-View | %{
$vm = $_
$vm.Config.Hardware.Device | where {$_.gettype().Name -eq "VirtualDisk"} | %{
if("physicalMode","virtualmode" -contains $_.Backing.CompatibilityMode){
$disk = $_.Backing.LunUuid.Substring(10,32)
$key = (Get-View $vm.Runtime.Host).Name.Split(".")[0] + "-" + $disk
$scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label
}
}
}
$scsiTab.GetEnumerator() | Group-Object -Property {$_.Key.Split("-")[1]} | %{
$lun = New-Object PSObject -Property @{
ClusterName = $clusName
CanonicalName = ''
UsedBy = ''
SizeMB = ''
PathPolicy = ''
}
$_.Group | %{
if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}
if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}
if(!$lun.SizeMB){$lun.SizeMB = $_.Value[2]}
if(!$lun.PathPolicy){$lun.PathPolicy = $_.Value[3]}
}
$lun
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you Master Luc!