Automation

 View Only
Expand all | Collapse all

PowerCli to pull RDM info

  • 1.  PowerCli to pull RDM info

    Posted Jan 25, 2013 07:46 PM

    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"



  • 2.  RE: PowerCli to pull RDM info

    Posted Jan 25, 2013 07:58 PM

    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


  • 3.  RE: PowerCli to pull RDM info

    Posted Jan 25, 2013 08:30 PM

    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)



  • 4.  RE: PowerCli to pull RDM info
    Best Answer

    Posted Jan 25, 2013 11:29 PM

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


  • 5.  RE: PowerCli to pull RDM info

    Posted Jan 29, 2013 10:40 PM

    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?



  • 6.  RE: PowerCli to pull RDM info

    Posted Jan 29, 2013 10:45 PM

    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.



  • 7.  RE: PowerCli to pull RDM info

    Posted Mar 05, 2013 10:34 PM

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



  • 8.  RE: PowerCli to pull RDM info

    Posted Mar 05, 2013 10:42 PM

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


  • 9.  RE: PowerCli to pull RDM info

    Posted Mar 05, 2013 11:23 PM

    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"



  • 10.  RE: PowerCli to pull RDM info

    Posted Mar 06, 2013 05:43 AM

    The clsoing parenthesis was at the wrong position, I corrected it above.

    Try again please.



  • 11.  RE: PowerCli to pull RDM info

    Posted Mar 07, 2013 10:00 PM

    Perfect!



  • 12.  RE: PowerCli to pull RDM info

    Posted Oct 10, 2017 07:08 AM

    Hi @LucD,

    You are awesome, can we also get only shared RDM details (only RDMs attached to the clustered VMs)?



  • 13.  RE: PowerCli to pull RDM info

    Posted Oct 10, 2017 07:26 AM

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



  • 14.  RE: PowerCli to pull RDM info

    Posted Sep 26, 2020 02:39 PM

    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.