Highlighted
Enthusiast
Enthusiast

Get RDM size

Jump to solution

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..????

0 Kudos
1 Solution

Accepted Solutions
Highlighted
User Moderator
User Moderator

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

0 Kudos
12 Replies
Highlighted
User Moderator
User Moderator

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

0 Kudos
Highlighted
Enthusiast
Enthusiast

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"){

0 Kudos
Highlighted
User Moderator
User Moderator

Can you attach the script you are using ?

I have no line 30 Smiley Sad


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

0 Kudos
Highlighted
Enthusiast
Enthusiast

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

At :line:26 char:21

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

0 Kudos
Highlighted
Enthusiast
Enthusiast

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

Any ideas ???

0 Kudos
Highlighted
User Moderator
User Moderator

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

0 Kudos
Highlighted
Enthusiast
Enthusiast

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

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

0 Kudos
Highlighted
Contributor
Contributor

Make sure you are connected to the vc

blog www.ivobeerens.nl

blog www.ivobeerens.nl
0 Kudos
Highlighted
Enthusiast
Enthusiast

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

0 Kudos
Highlighted
Contributor
Contributor

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..

0 Kudos
Highlighted
Immortal
Immortal

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]

0 Kudos
Highlighted
Contributor
Contributor

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

0 Kudos