PowerCLI

 View Only
Expand all | Collapse all

list disks rdm with powershell

LucD

LucDJan 06, 2009 10:05 AM

jsenon

jsenonOct 26, 2009 09:29 PM

wamatha

wamathaOct 18, 2011 04:30 PM

  • 1.  list disks rdm with powershell

    Posted Sep 29, 2008 07:17 AM

    Hello ,

    i like how lists disk rdm of a vm .Command get-hardisk give me location vmdk , capacity , but i want more informatation disks RDMs

    Por example , i want to list imformation like vmhba 1:0:9:0 , SCSI (2:1) , etc for each disk .

    Someone can gime some help

    Thanks



  • 2.  RE: list disks rdm with powershell

    Posted Sep 29, 2008 08:17 AM

    This gives the devicename of each RDM disk for each vm.

    $report = @()
    $vms = Get-VM | Get-View
    foreach($vm in $vms){
      foreach($dev in $vm.Config.Hardware.Device){
        if(($dev.gettype()).Name -eq "VirtualDisk"){
    	  if($dev.Backing.CompatibilityMode -eq "physicalMode"){
    	    $row = "" | select VMName, HDDeviceName, HDFileName
              $row.VMName = $vm.Name
    	    $row.HDDeviceName = $dev.Backing.DeviceName
    	    $row.HDFileName = $dev.Backing.FileName
    	    $report += $row
    	  }
    	}
      }
    }
    $report
    



  • 3.  RE: list disks rdm with powershell

    Posted Oct 01, 2008 12:32 AM

    Hi LucD,

    Can you please check attached Script since is not producing any result.

    Regards,



  • 4.  RE: list disks rdm with powershell

    Posted Oct 01, 2008 05:01 AM

    Could it be that there are no raw disks ?

    Perhaps try without the test for "physicalMode".

    $report = @() 
    $vms = Get-VM | Get-View 
    foreach($vm in $vms) {
    			foreach($dev in $vm.Config.Hardware.Device)	{
    				if(($dev.gettype()).Name -eq "VirtualDisk")	{ 
    #					if($dev.Backing.CompatibilityMode -eq "physicalMode"){ 
    						$row = "" | select VMName, HDDeviceName, HDFileName 
    						$row.VMName = $vm.Name 
    						$row.HDDeviceName = $dev.Backing.DeviceName 
    						$row.HDFileName = $dev.Backing.FileName 
    							$report += $row 
    					} 	
    #				} 
    			} 
    } 
    $report
    



  • 5.  RE: list disks rdm with powershell

    Posted Oct 01, 2008 06:27 AM

    Thanks mate, is working now:

    $report = @()

    $vms = Get-VM | Get-View

    foreach($vm in $vms) {

    foreach($dev in $vm.Config.Hardware.Device) {

    if(($dev.gettype()).Name -eq "VirtualDisk") {

    $row = "" | select VMName, HDDeviceName, HDFileName

    $row.VMName = $vm.Name

    $row.HDDeviceName = $dev.Backing.DeviceName

    $row.HDFileName = $dev.Backing.FileName

    $report += $row

    }

    }

    }

    $report



  • 6.  RE: list disks rdm with powershell

    Posted Oct 01, 2008 11:23 AM

    Just came to realise that RDMs come in 2 flavours, physical and virtual.

    Since I only tested for physical and your RDMs are probably in virtual compatibility mode they didn't show.

    This script should only show RDMs but for both compatibility modes

    $report = @()
    $vms = Get-VM | Get-View
    foreach($vm in $vms){
      foreach($dev in $vm.Config.Hardware.Device){
        if(($dev.gettype()).Name -eq "VirtualDisk"){
    	  if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or 
    	     ($dev.Backing.CompatibilityMode -eq "virtualMode")){
    	    $row = "" | select VMName, HDDeviceName, HDFileName, HDMode
              $row.VMName = $vm.Name
    	    $row.HDDeviceName = $dev.Backing.DeviceName
    	    $row.HDFileName = $dev.Backing.FileName
    	    $row.HDMode = $dev.Backing.CompatibilityMode
    	    $report += $row
    	  }
    	}
      }
    }
    $report
    



  • 7.  RE: list disks rdm with powershell

    Posted Dec 12, 2008 03:44 PM

    This script is great. Just as an FYI, instead of looking for disks that are virtual or physical mode, I looked for disks that were not equal to flat.



  • 8.  RE: list disks rdm with powershell

    Posted Jan 06, 2009 09:47 AM

    Hi all ....

    I was wondering how to add the RDM size to this table ??

    Kind regards



  • 9.  RE: list disks rdm with powershell

    Posted Jan 06, 2009 10:05 AM

    The answer is in



  • 10.  RE: list disks rdm with powershell

    Posted Apr 22, 2009 01:05 PM

    Hi,

    This script is great is there a way to get it to output what ESX host the VMs are on?? Is there a property for the host within the $vm object??? something like $vm.Host??

    Thanks

    Emma



  • 11.  RE: list disks rdm with powershell

    Posted Apr 22, 2009 01:20 PM

    Yes, the VirtualMachine object contains, under the Runtime.Host property, a MoRef to the host on which the VM is running or assigned.

    The script could then be something like this:

    $report = @()
    $vms = Get-VM  | Get-View
    foreach($vm in $vms){
      foreach($dev in $vm.Config.Hardware.Device){
        if(($dev.gettype()).Name -eq "VirtualDisk"){
    	  if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or 
    	     ($dev.Backing.CompatibilityMode -eq "virtualMode")){
    	    $row = "" | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize
              $row.VMName = $vm.Name
    	    $row.VMHost = (Get-View $vm.Runtime.Host).Name
    	    $row.HDDeviceName = $dev.Backing.DeviceName
    	    $row.HDFileName = $dev.Backing.FileName
    	    $row.HDMode = $dev.Backing.CompatibilityMode
               $row.HDSize = $dev.CapacityInKB
    	    $report += $row
    	  }
    	}
      }
    }
    $report
    



  • 12.  RE: list disks rdm with powershell

    Posted Apr 22, 2009 02:15 PM

    Thanks LucD

    Thats great! And a useful link so hopefully i can work more out for myself!

    E



  • 13.  RE: list disks rdm with powershell

    Posted Jun 19, 2009 03:00 AM

    thanks man, this is such a useful script !

    Kind Regards,

    AWT



  • 14.  RE: list disks rdm with powershell

    Posted Sep 21, 2009 02:22 PM

    Does anyone know how to add the device name to the output? For example, instead of just the vmhba notitation, can you also get something like this:

    EMC Fibre Channel Disk (naa.60060480000190100744533031393736)

    Thanks!

    Tom Cronin, VCP, VMware vExpert 2009 - Co-Leader Buffalo, NY VMUG



  • 15.  RE: list disks rdm with powershell

    Posted Sep 21, 2009 08:52 PM

    I suspect you are after the DisplayName as it's called in the SDK Reference.

    Try this script, the DisplayName has been added.

    $report = @()
    $vms = Get-VM | Get-View
    foreach($vm in $vms){
    	foreach($dev in $vm.Config.Hardware.Device){
    		if(($dev.gettype()).Name -eq "VirtualDisk"){
    			if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or 
    			($dev.Backing.CompatibilityMode -eq "virtualMode")){
    				$row = "" | select VMName, VMHost, HDDeviceName, HDFileName, HDMode, HDsize, HDDisplayName
    				$row.VMName = $vm.Name
    				$esx = Get-View $vm.Runtime.Host
    				$row.VMHost = ($esx).Name
    				$row.HDDeviceName = $dev.Backing.DeviceName
    				$row.HDFileName = $dev.Backing.FileName
    				$row.HDMode = $dev.Backing.CompatibilityMode
    				$row.HDSize = $dev.CapacityInKB
    				$row.HDDisplayName = ($esx.Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev.Backing.LunUuid}).DisplayName
    				$report += $row
    			}
    		}
    	}
    }
    $report
    



  • 16.  RE: list disks rdm with powershell

    Posted Oct 23, 2009 02:21 PM

    Thanks LucD.

    Is it possible to add Runtime Name and Lun Name in the display of your script ?

    (This data is available in VCenter 4, on manage Path of the RDM Disk)

    Thanks in advance,

    Regads,



  • 17.  RE: list disks rdm with powershell

    Posted Oct 26, 2009 09:29 PM

    Hi,

    nobody have an idea ?

    Thanks.



  • 18.  RE: list disks rdm with powershell

    Posted Oct 18, 2011 04:30 PM

    Ho do I export his to csv file?



  • 19.  RE: list disks rdm with powershell

    Posted Nov 10, 2011 01:06 PM

    Did you get an answer for this? i am really bad at scripting and would like tis info also for this script in particular

    Thanks!



  • 20.  RE: list disks rdm with powershell

    Posted Nov 10, 2011 01:38 PM

    Which script are you talking about ?



  • 21.  RE: list disks rdm with powershell

    Posted Nov 10, 2011 01:44 PM

    the one from notorious_bd



  • 22.  RE: list disks rdm with powershell

    Posted Nov 10, 2011 01:54 PM

    Try the attached version



  • 23.  RE: list disks rdm with powershell

    Posted Nov 10, 2011 02:02 PM

    Awesome! You are the best!

    Thank you very much!



  • 24.  RE: list disks rdm with powershell

    Posted Nov 28, 2011 05:28 PM

    LucD, thanks for posting that script!  It's gotten me halfway to the report I'm trying to build.  I'm wondering if someone here can help me get the rest of the info I want.

    I'm trying to build a report that has the following columns:  Host, VM, Disk Number, LUN ID, Runtime Name, Target, Status.  Using LucD's script as a starting point I've got a script that will give me the first 4 columns, but can't figure out where to get the Runtime Name, Target or Status.  Another problem is that this appears to only show each disk once, and I'm going to want each disk 4 times (once for each path - two HBA's, each dual pathed - because the runtime name will be different for each path).  My script is attached, any help you all can give me would be appreciated!  Thanks!



  • 25.  RE: list disks rdm with powershell

    Posted Nov 28, 2011 06:37 PM

    To get the terminology clear, you mean RuntimeName, Target and Status as it appears on the View Paths panel in the vSphere Client ?



  • 26.  RE: list disks rdm with powershell

    Posted Nov 28, 2011 07:03 PM

    Yes, that is correct.  Thanks!



  • 27.  RE: list disks rdm with powershell

    Posted Dec 05, 2011 08:38 PM

    Here is my latest script for anyone who may find it useful.  I've added a couple more fields other than what my previous post said I was looking for.  And I never could find where to get the Target or Status fields, but my customer said that wasn't important, so I'm not too worried about getting it.  If anyone knows how/where to get those though, I'd still be interested in learning.



  • 28.  RE: list disks rdm with powershell

    Posted Dec 11, 2012 09:12 AM

    Hi
    I have tried to run your script, but report.csv is empty, what do I do wrong?

    Best regards

    Henrik Priergaard 



  • 29.  RE: list disks rdm with powershell

    Posted Dec 11, 2012 02:35 PM

    Henrik,

    Here is the most recent version of the script that I'm using.  There are a couple of lines you will need to change where I've removed my company's information and you'll have to put your company's information in.

    In the line:

         Connect-VIServer -Server servername -WarningAction:SilentlyContinue

    You will need to replace "servername" with the name of the vCenter server you want to connect to.  You will also need to run the script under a user account that has access to that vCenter server, or you will need to specifiy other credentials in the script.

    In the line:

         foreach ($folder in (Get-View -ViewType "Folder" -Filter @{"Name" = "Folder name"}))

    You will need to replace "Folder name" with the actual name of the folder you want to gather info from.  I only care about certain folders, so that is why I filter it down like that.  If you want to run the script against everything and not filter down to certain folders you can replace that entire for-loop with the lines:

         $Hosts += Get-View -ViewType "HostSystem"

         $VMs += Get-View -ViewType "VirtualMachine"

    I think that should get you a report if you do that.  Let me know if you still have problems.

    Chad



  • 30.  RE: list disks rdm with powershell

    Posted Aug 02, 2013 04:43 PM

    Hello Chad,

    Its good script. But I am looking a script to get the selected VM or all the VMs who has DiskType -eq “RawPhysical”, details with Properties (Host, VM, DiskNumber, Identifier, Policy, VirtualDeviceNode, Capacity )

    Can you assist ?

    I tried this as below --

    Function Get-RAWDiskInfo {

    $RDisks = Get-VM $VM | Get-HardDisk | Where {$_.DiskType -eq “RawPhysical”}

    Foreach ($RDisk in $RDisks) {

    $Lun = Get-VMHost -name (Get-VM $VM).VMHost | Get-SCSILun $RDisk.SCSICanonicalName

    $Props = @{ 'VM Name' = $RDisk.Parent;

                'DiskType' = $RDisk.DiskType;

                'Name' = $RDisk.Name;

                'Filename' = $RDisk.Filename;

                'Scsi Name' = $RDisk.ScsiCanonicalName;

                'LUN ID' = $Lun.RuntimeName.Substring($Lun.RuntimeName.LastIndexof(“L”)+1)

             

                }

    New-Object -TypeName PSObject -Property $props

    }

    }



  • 31.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 01:03 PM

    LucD, for the RDM-Report.ps1 script, is it possible to include a column that reports the Perennially Reserved status of each LUN?



  • 32.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 01:05 PM

    Since there are many version of the script floating around in this thread, would you mind attaching the one you are using?



  • 33.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 01:38 PM

    Sorry, LucD​. Surprisingly, I actually figured this out on my own since posting the question. Here's what I pieced together for my particular needs:

    $clusterName = 'ClusterName'
    $cluster = Get-Cluster -Name $clusterName
    $luns = Get-VM -Location $cluster | Get-HardDisk | where{$_.DiskType -match '^Raw'} | Select -ExpandProperty ScsiCanonicalName

    Get-VMHost -Location $cluster | %{
    $esxcli = Get-EsxCli -VMHost $_ -V2
    $esxcli.storage.core.device.list.Invoke() | where{$luns -contains $_.Device} | Select @{N='VMHost';E={$esxcli.VMHost.Name}},Device,@{N='SizeGB';E={$_.Size/1KB}},IsPerenniallyReserved
    }

    This displayed a list of RDM disks, the ESXi host it is attached to, the size, and the Perennially Reserved status. Thanks for the ultra-fast reply (and for all you do for the VMware community!)



  • 34.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 01:40 PM

    Great, and thanks for sharing.



  • 35.  RE: list disks rdm with powershell

    Posted Apr 19, 2017 07:06 PM

    LucD​, thanks for this script with the DisplayName added! It really helped me find the information I was looking for! Thank you!



  • 36.  RE: list disks rdm with powershell

    Posted Oct 31, 2009 08:08 PM

    This script is very helpful. I have trying to figure out how to add 'Runtime Name:' and 'Adpater:' information to this report.

    Any thoughts on how to do this?

    Thanks in advance.

    -Mark

    fc.200000e08b9bad3f:210000e08b9bad3f-fc.50060160c1e02ae9:5006016141e02ae9-naa.60060160efe01900c883b8dee114de11

    Runtime Name: vmhba1:C0:T0:L22

    Device: naa.60060160efe01900c883b8dee114de11

    Device Display Name: DGC Fibre Channel Disk (naa.60060160efe01900c883b8dee114de11)

    Adapter: vmhba1 Channel: 0 Target: 0 LUN: 22

    Adapter Identifier: fc.200000e08b9bad3f:210000e08b9bad3f

    Target Identifier: fc.50060160c1e02ae9:5006016141e02ae9

    Plugin: NMP

    State: active

    Transport: fc

    Adapter Transport Details: WWNN: 20:00:00:e0:8b:9b:ad:3f WWPN: 21:00:00:e0:8b:9b:ad:3f

    Target Transport Details: WWNN: 50:06:01:60:c1:e0:2a:e9 WWPN: 50:06:01:61:41:e0:2a:e9



  • 37.  RE: list disks rdm with powershell

    Posted Feb 17, 2010 06:00 PM

    Handy script. Did anyone manage to work out how to report lun number and vmhba path...

    The script currently gives:

    VMName : ctx01

    VMHost : esx1.corp.com

    HDDeviceName : vml.020000000060a9800050334c77465a5256777954344c554e202020

    HDFileName : ctx01/ctx01_1.vmdk

    HDMode : physicalMode

    HDsize : 10485760

    HDDisplayName : NETAPP Fibre Channel Disk (naa.60a9800050334c77465a525677795434)

    But I was hoping to see -

    LUNnumber : 102

    VMhbapath: vmhba1:0:102

    Any ideas?

    Regards

    Mike Laverick

    RTFM Education

    http://www.rtfm-ed.co.uk

    Author of the SRM Book:http://stores.lulu.com/rtfm

    Free PDF or at-cost Hard Copy



  • 38.  RE: list disks rdm with powershell

    Broadcom Employee
    Posted Feb 17, 2010 06:31 PM

    This should be pretty trivial by pulling out deviceName property, I'm sure Luc or Alan could help with pulling that out as well.

    Here is a vSphere SDK for Perl script that utilizes this property to displays the vmhba path and you can extract the LUN # from that as well.

    =========================================================================

    William Lam

    VMware vExpert 2009

    VMware ESX/ESXi scripts and resources at:

    Twitter: @lamw

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    VMware Developer Comuunity

    If you find this information useful, please award points for "correct" or "helpful".



  • 39.  RE: list disks rdm with powershell

    Posted Feb 18, 2010 01:41 AM

    I use this code I use to report info for all LUNs, vmfs and rdm. It includes the host LUN number plus much more. I'm not sure how to get the runtime name yet, but I question the usefulness in this report since the runtime name can be different on each ESX Server. If you add runtime name, you'll have to show it for each ESX Server with access to the LUN.

    $RDMs = @()
    foreach($vm in (Get-View -ViewType "VirtualMachine")) {
      foreach($dev in ($vm.Config.Hardware.Device | where {($_.gettype()).Name -eq "VirtualDisk"})) {
        if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or ($dev.Backing.CompatibilityMode -eq "virtualMode")) {
          $objRdm            = "" | select VMName, VMDK, UUID, DiskLabel, SCSIBus, SCSIDevice, Mode
          $objRdm.VMName     = $vm.Name
          $objRdm.VMDK       = $dev.Backing.FileName
          $objRdm.UUID       = $dev.Backing.LunUuid
          $objRdm.DiskLabel  = $dev.DeviceInfo.Label
          $objRdm.SCSIBus    = ( $vm.Config.Hardware.Device | ? { $_.Key -eq $dev.ControllerKey }).BusNumber
          $objRdm.SCSIDevice = $dev.UnitNumber
          $objRdm.Mode       = $dev.Backing.CompatibilityMode
          $RDMs += $objRdm
        }
      }
    }
    foreach ($cluster in (Get-View -ViewType "ClusterComputeResource")) {
      $vmhostsview = $cluster.host | % { Get-View $_ }
      $vmhostview  = $vmhostsview | Select -first 1
      $ScsiLuns    = $vmhostsview | % { $_.Config.StorageDevice.ScsiLun } | Select -unique *
      $UUIDs       = $ScsiLuns | Select -unique UUID
      $Datastores  = $vmhostsview | % { $_.Config.FileSystemVolume.MountInfo } | % { $_.Volume } | Select -Unique *
      $HostLUN     = $vmhostsview | % { $_.Config.StorageDevice.ScsiTopology.Adapter } | % { $_.Target | % { $_.LUN } } | Select -unique *
      foreach ($UUID in $UUIDs) {
        $Lun = $ScsiLuns | ? { $_.UUID -eq $UUID.UUID } | Select -first 1
        $objVolume               = "" | Select Cluster, VolumeName, CanonicalName, DisplayName, VolumeType, CapacityGB, BlockSizeMb, VMFSVersion, LunType, Vendor, Model, HostLUN, VM, VMDiskLabel, VMSCSIBus, VMSCSIDevice, Revision, ScsiLevel, UUID
        $objVolume.Cluster       = $cluster.Name
        $objVolume.CanonicalName = $Lun.CanonicalName
        $objVolume.HostLUN       = ($HostLUN | ? { $_.ScsiLun -eq $Lun.Key } | select -unique LUN).LUN
        $objVolume.UUID          = $Lun.Uuid
        $objVolume.CapacityGB    = $Lun.Capacity.Block * $Lun.Capacity.BlockSize / 1GB
        $objVolume.DisplayName   = $Lun.DisplayName
        $objVolume.LunType       = $Lun.LunType
        $objVolume.Vendor        = $Lun.Vendor
        $objVolume.Model         = $Lun.Model
        $objVolume.Revision      = $Lun.Revision
        $objVolume.ScsiLevel     = $Lun.ScsiLevel
        foreach ($vol in $Datastores) {
          if ($vol.extent | % { $_.diskname -eq $Lun.CanonicalName}) {
            $objVolume.VolumeName  = $vol.Name
            $objVolume.BlockSizeMb = $vol.BlockSizeMb
            $objVolume.VMFSVersion = $vol.Version
            $objVolume.VolumeType  = "vmfs"
          }
        }
        foreach ($rdm in $RDMs) {
          if ($Lun.Uuid -eq $rdm.UUID) {
            $objVolume.VolumeName   = $rdm.VMDK
            $objVolume.VM           = $rdm.VMName
            $objVolume.VMDiskLabel  = $rdm.DiskLabel
            $objVolume.VMSCSIBus    = $rdm.SCSIBus 
            $objVolume.VMSCSIDevice = $rdm.SCSIDevice
            if ($rdm.Mode -eq "virtualMode" ) { $objVolume.VolumeType  = "rdm"  }
            if ($rdm.Mode -eq "physicalMode") { $objVolume.VolumeType  = "rdmp" }
          }
        }
        $objVolume
      }
    }
    



  • 40.  RE: list disks rdm with powershell

    Posted Jul 28, 2010 08:53 PM

    Thanks for these great scripts. I am using one of these scripts in a datacenter with multiple clusters. When the information is output via html, it adds multiple instances of the clusters. Is there a way to run this and designate the cluster to gather the desired datastore information? I have tried modifying to no avail. Also, can it be setup to do a sort by the HostLun or VolumeName? Here is my modified script:

    1. ---- Hosts Storage Information ----

    if ($ShowHostStorageInfoProd){

    Write-CustomOut "..Checking Hosts Storage Information"

    $ShowHostStorage = @()

    foreach ($cluster in (Get-View -ViewType ClusterComputeResource)) {

    $vmhostsview = $cluster.host | % { Get-View $_ }

    $vmhostview = $vmhostsview | Select -first 1

    $ScsiLuns = $vmhostsview | % { $_.Config.StorageDevice.ScsiLun } | Select -unique *

    $UUIDs = $ScsiLuns | Select -unique UUID

    $Datastores = $vmhostsview | % { $_.Config.FileSystemVolume.MountInfo } | % { $_.Volume } | Select -Unique *

    $HostLUN = $vmhostsview | % { $_.Config.StorageDevice.ScsiTopology.Adapter } | % { $_.Target | % { $_.LUN } } | select -unique *

    foreach ($UUID in $UUIDs) {

    $Lun = $ScsiLuns | ? { $_.UUID -eq $UUID.UUID } | Select -first 1

    $objVolume = "" | Select Cluster, VolumeName, HostLUN, CanonicalName, DisplayName, VolumeType, CapacityGB, BlockSizeMb, VMFSVersion, LunType, Vendor, Model, Revision, ScsiLevel, UUID

    $objVolume.Cluster = $cluster.Name

    $objVolume.CanonicalName = $Lun.CanonicalName

    $objVolume.HostLUN = ($HostLUN | ? { $_.ScsiLun -eq $Lun.Key } | select -unique LUN).LUN

    $objVolume.UUID = $Lun.Uuid

    $objVolume.CapacityGB = $Lun.Capacity.Block * $Lun.Capacity.BlockSize / 1GB

    $objVolume.DisplayName = $Lun.DisplayName

    $objVolume.LunType = $Lun.LunType

    $objVolume.Vendor = $Lun.Vendor

    $objVolume.Model = $Lun.Model

    $objVolume.Revision = $Lun.Revision

    $objVolume.ScsiLevel = $Lun.ScsiLevel

    foreach ($vol in $Datastores) {

    if ($vol.extent | % { $_.diskname -eq $Lun.CanonicalName}) {

    $objVolume.VolumeName = $vol.Name

    $objVolume.BlockSizeMb = $vol.BlockSizeMb

    $objVolume.VMFSVersion = $vol.Version

    $objVolume.VolumeType = "vmfs"

    }

    }

    $ShowHostStorage += $objVolume

    }

    If (($ShowHostStorage | Measure-Object).count -ge 0) {

    $MyReport += Get-CustomHeader "Production Host Storage Detailed Information" "The following provides a detailed list of the Hosts and LUNs presented to the Hosts in a Cluster"

    $MyReport += Get-HTMLTable $ShowHostStorage

    $MyReport += Get-CustomHeaderClose

    }

    }

    }



  • 41.  RE: list disks rdm with powershell

    Posted Jul 29, 2010 05:00 AM

    To select a sprecific cluster you can modify this line

    foreach ($cluster in (Get-View -ViewType ClusterComputeResource)) {
    

    into

    foreach ($cluster in (Get-View -ViewType ClusterComputeResource -Filter @{"Name"="myClusterName"})) {
    

    To sort the results you can change this line

    $MyReport += Get-HTMLTable $ShowHostStorage
    

    into this

    $MyReport += Get-HTMLTable ($ShowHostStorage | Sort-Object -Property HostLUN)
    

    or

    $MyReport += Get-HTMLTable ($ShowHostStorage | Sort-Object -Property VolumeName)
    

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 42.  RE: list disks rdm with powershell

    Posted Jul 29, 2010 01:58 PM

    Can't thank you enough. The lump on my forehead was starting to grow. :smileyhappy:

    Worked perfectly!!!



  • 43.  RE: list disks rdm with powershell

    Posted Dec 01, 2010 11:35 AM

    Thanks for these scripts...

    I ran it against our clusters and because we have some LUNs mapped to the cluster but not used as vmfs or rdms we got odd results. Basically we got false positives on one of the if statements causing the wrong volume name etc...

    I have reversed the test to a negative test and this seems to have sorted the issue. The clip below doesnt do anything is positive however you might want to set the Volume name to "Unused" or something.

    if ($vol.extent | % { $_.diskname -ne $Lun.CanonicalName}) {

    #Do Nothing

    } ELSE {

    $objVolume.VolumeName = $vol.Name

    $objVolume.BlockSizeMb = $vol.BlockSizeMb

    $objVolume.VMFSVersion = $vol.Version

    $objVolume.VolumeType = $vol.Type

    }

    Thanks again

    Regards

    Mark



  • 44.  RE: list disks rdm with powershell

    Posted Dec 01, 2010 11:55 AM

    My LUN report – datastore, RDM and node visibility has a script that shows all LUNs, irrespective if they are used as VMFS or RDM or even not used atll.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 45.  RE: list disks rdm with powershell

    Posted Jul 17, 2017 09:09 AM

    Big thanks to you. I am following you past 4 years.. When ever i am searching any script for PowerCli, at least google will provide your two scripts.

    Now my requirement is need VM information with RDM status only ( RDM presented or not). Not required for RDM details. I have modified your script.

    Request to review the script. i will believe i done some mistake.

    @LucD



  • 46.  RE: list disks rdm with powershell

    Posted Jul 17, 2017 09:44 AM

    Try like this

    $report = @()

    $vmList = Get-Content C:\temp\VM.txt

    $vms = Get-VM $vmList

    foreach($vm in $vms){

      foreach($dev in $vm.ExtensionData.Config.Hardware.Device){

        if(($dev.gettype()).Name -eq "VirtualDisk"){

           if($dev.Backing.CompatibilityMode -eq "physicalMode")

         {

    $rdm = "yes"

            }

        else {

        $rdm = "no"

        }

    $row = "" | select VMName, Cluster, ESXHost, Datastore, NetworkName, RDM

             $row.VMName = $vm.Name

    $row.Cluster = get-cluster -VM $vm

             $row.ESXHost = Get-VMHost -VM $vm

    $row.Datastore = Get-Datastore -VM $vm

             $row.NetworkName = (get-vm $vm | Get-NetworkAdapter).NetworkName

    $row.RDM = $rdm

             $report += $row

         }

      }

    }

    $report



  • 47.  RE: list disks rdm with powershell

    Posted Jul 17, 2017 03:00 PM

    As Usually you are awesome :smileyhappy:

    Working like a charm.

    Really appreciate your help.



  • 48.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 06:52 AM

    Hi LuCD,

    One more help, after running this script i am getting multiple lines of same VM( Based on number of disk). Is it possible to display only one line for VM and need to add vCenter name in additional column. .



  • 49.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 06:58 AM


  • 50.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 07:06 AM

    Thanks. I will helpful. How i can add vCenter Name in Column. Before we are connecting two vCenter.



  • 51.  RE: list disks rdm with powershell

    Posted Jul 18, 2017 07:12 AM

    The vCenter can be derived from the Uid property on the HardDisk object.

    Something like this

    Get-VM -Name MyVM | Get-HardDisk |

    Select Name,

        @{N='VM';E={$_.Parent.Name}},

        @{N='vCenter';E={$_.Uid.Split('@')[1].Split(':')[0]}}