VMware Cloud Community
gboskin
Enthusiast
Enthusiast
Jump to solution

Get RDM size

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
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could use the script from .

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
12 Replies
LucD
Leadership
Leadership
Jump to solution

You could use the script from .

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
gboskin
Enthusiast
Enthusiast
Jump to solution

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
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you attach the script you are using ?

I have no line 30 Smiley Sad


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
gboskin
Enthusiast
Enthusiast
Jump to solution

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

At :line:26 char:21

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

Reply
0 Kudos
gboskin
Enthusiast
Enthusiast
Jump to solution

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
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
gboskin
Enthusiast
Enthusiast
Jump to solution

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

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

Reply
0 Kudos
ief
Contributor
Contributor
Jump to solution

Make sure you are connected to the vc

blog www.ivobeerens.nl

blog www.ivobeerens.nl
Reply
0 Kudos
gboskin
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
GeorgeYacubovic
Contributor
Contributor
Jump to solution

Did you figure out?

I am searching for how to monitor and report the details RDM disks on important VMs (i.e. the physical disk RDMs without logical disk letters that are associated wiht Exchange 2007 Storage Groups)

I would like to be able to report on free space remaining.

Thanks in advance..

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

What you're asking for is a bit more than what I see above.

Check out this script from Hugo Peeters. He mixes PowerCLI with WMI calls to fill in guest information. I assume it will work for volumes without drive letters but if not I bet you can tweak it slightly to what you need.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

Reply
0 Kudos
GeorgeYacubovic
Contributor
Contributor
Jump to solution

Thank you for the pointer. If it is what I'm after; great. If I'm able to tweak it. I'll post it.

Reply
0 Kudos