VMware Cloud Community
online11
Contributor
Contributor
Jump to solution

List VMFS and RAW disks with naa.id and multipath policy

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.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
online11
Contributor
Contributor
Jump to solution

Thank you Master Luc!

0 Kudos