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..????
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.
You cannot call a method on a null-valued expression.
At :line:26 char:21
+ if(($dev.gettype( <<<< )).Name -eq "VirtualDisk"){
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]