Automation

 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