VMware Communities > VMTN > VMware vSphere™ > Automation Tools > vSphere™ PowerCLI > Discussions

This Question is Answered

2 "helpful" answers available (6 pts)
9 Replies Last post: Jan 6, 2009 6:19 AM by gboskin
Reply

Get RDM size

Jan 6, 2009 12:51 AM

Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008

Hi all and a happy new year to evryone..

The Following script gives a good list of all the RDM ..

$report1 = @()

$vms = Get-VM |Sort Name -Descending | 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

+$report1 = $row

}

}

}

}

$report1 | ConvertTo-Html -title "Virtual Machine information" -body "<H2>RDM information.</H2>" -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation


is there a way i can get the actual size (capacity) of the RDms..????

Reply Re: Get RDM size Jan 6, 2009 2:02 AM
Click to view LucD's profile Champion LucD 2,384 posts since
Oct 31, 2005
You could use the script from list disks rdm with powershell.
With a minor adaption it will also display the disk capacity.
$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, HDsize
          $row.VMName = $vm.Name
	    $row.HDDeviceName = $dev.Backing.DeviceName
	    $row.HDFileName = $dev.Backing.FileName
	    $row.HDMode = $dev.Backing.CompatibilityMode
           $row.HDSize = $dev.CapacityInKB
	    $report += $row
	  }
	}
  }
}
$report

An RDM is mapped via a .vmdk file.
Through the .vmdk file the size can be obtained.
Reply Re: Get RDM size Jan 6, 2009 2:36 AM
in response to: LucD
Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008

I seem to be getting an error

You cannot call a method on a null-valued expression.

At :line:30 char:21

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

Reply Re: Get RDM size Jan 6, 2009 2:49 AM
in response to: gboskin
Click to view LucD's profile Champion LucD 2,384 posts since
Oct 31, 2005
Can you attach the script you are using ?
I have no line 30 :-(
Reply Re: Get RDM size Jan 6, 2009 3:00 AM
in response to: LucD
Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008

You cannot call a method on a null-valued expression.

At :line:26 char:21

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

Attachments:
Reply Re: Get RDM size Jan 6, 2009 3:16 AM
in response to: gboskin
Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008

Strange if i run the same script pointing to a diffrent Vcenter is works..?????????????? Point it back I get the same error

Any ideas ???

Reply Re: Get RDM size Jan 6, 2009 4:02 AM
in response to: gboskin
Click to view LucD's profile Champion LucD 2,384 posts since
Oct 31, 2005
Are you running the samve VC version on both ?
Different versions use different APIs.
It could be that one VC doesn't support all the objects.
Reply Re: Get RDM size Jan 6, 2009 4:15 AM
in response to: LucD
Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008

yes exactly the same version ..was working ok till this afternoon..

Think i will have do give it a chinese cure " reboot vCenter"....

Reply Re: Get RDM size Jan 6, 2009 5:52 AM
in response to: gboskin
Click to view ief's profile Enthusiast ief 28 posts since
Aug 19, 2005
Make sure you are connected to the vc


blog www.ivobeerens.nl

Reply Re: Get RDM size Jan 6, 2009 6:19 AM
in response to: ief
Click to view gboskin's profile Hot Shot gboskin 206 posts since
Nov 19, 2008
Yes good old "Reboot" Vcenter solved the problem..

My next task is

1) how to add the Percentage of the RDM used .. ( Monitor the space left on the RDM)

2) List all RDM with less than 10% free

Actions