I use the following script to pull matrix from all my vCenter's. We have some RDM's that I want to capture in this as well... is it doable?
When I say capture... Im looking to pull the # of RDM's as well as total space being used by them.
"Total Datacenters: $(@(Get-Datacenter).Count)"
"Total Clusters: $(@(Get-Cluster).Count)"
"Total ESX Hosts: $(@(Get-VMHost).Count)"
"Total VM's: $(@(Get-VM).Count)"
"Total Templates: $(@(Get-Template).Count)"
"Total LUN Datastores: $(@(Get-Datastore).Count)"
$TotalDatastoresCapacityMB = 0
Get-Datastore | ForEach-Object { $TotalDatastoresCapacityMB += $_.CapacityMB }
$TotalDatastoresCapacityGb = $TotalDatastoresCapacityMB/1024
"Total Size of LUN Datastores in GB: $TotalDatastoresCapacityGb"
Ok, then try it like this
$rdms = Get-VM | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DIskType} "VM with RDM: $(($rdms | Sort-Object -Property {$_.Parent.Name} -Unique).Count)"
"Total RDM size GB $($rdms | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure, that is doable.
Try something like this
Get-VM | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DiskType} |
Select @{N="VM";E={$_.Parent.Name}},Name,ScsiCanonicalName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Heres the output I get when I add that line...
Total Datacenters: 1
Total Clusters: 2
Total ESX Hosts: 20
Total VM's: 1024
Total Templates: 38
Total LUN Datastores: 55
VM Name ScsiCanonicalName
-- ---- -----------------
VM1 Hard disk 3 naa.60a980006465647448...
VM2 Hard disk 4 naa.60a980006465647448...
Im looking for it to basically get me the number of VM's that have RDM's and the storage size allocated to them.... I dont need the iSCSI name either. just VM count and RDM size in GB's (preferably)
Ok, then try it like this
$rdms = Get-VM | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DIskType} "VM with RDM: $(($rdms | Sort-Object -Property {$_.Parent.Name} -Unique).Count)"
"Total RDM size GB $($rdms | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked great....
Im assuming that based on the script I pasted, that the Total RDM size is in ADDITION to the Total size of LUN Datastores, right?
Correct, for the Total RDM size the script adds the capacity of the LUNs used for RDMs.
The LUNs used for datastores are not in there.
Note, there is a small overhead, in that a RDM disk also has a VMDK header file that is stored with the files of the VM on a datastore.
But the size of these RDM header VMDK files is very small.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there a way to change the GB to TB in the "Total RDM size in GB"
I can change it in the LUN side, but not sure if CapacityGB can be changed at all....
Try like this
$rdms = Get-VM | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DIskType} "VM with RDM: $(($rdms | Sort-Object -Property {$_.Parent.Name} -Unique).Count)" "Total RDM size TB $(($rdms | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum)/1KB)"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It didnt actually divide the number.
Here's the output:
Total RDM size TB 91623.8641958237/1KB
With this being the script:
$rdms = Get-VM | Get-HardDisk | where {"RawPhysical","RawVirtual" -contains $_.DIskType}
"VM with RDM: $(($rdms | Sort-Object -Property {$_.Parent.Name} -Unique).Count)"
"Total RDM size TB $(($rdms | Measure-Object -Property CapacityGB -Sum | Select -ExpandProperty Sum))/1KB"
The clsoing parenthesis was at the wrong position, I corrected it above.
Try again please.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect!
Hi @LucD,
You are awesome, can we also get only shared RDM details (only RDMs attached to the clustered VMs)?
Sure, try something like this
Get-VM | Get-HardDisk |
where {"RawPhysical","RawVirtual" -contains $_.DiskType -and
"Physical","Virtual" -contains (Get-ScsiController -HardDisk $_).BusSharingMode} |
Select @{N='VM';E={$_.Parent.Name}},
Name,
FileName,
CapacityGB,
DiskType,
ScsiCanonicalName,
@{N='BusSharing';E={(Get-ScsiController -HardDisk $_).BusSharingMode}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LuCD,
Sorry for opening the old thread. Can you please help to suggest if we can able to include the SCSI controller (LSI or VMware paravirtual) and the RDM disk bus sharing mode (No sharing or Multiwriter) as well?
Thank you
Regards
Narayanan.