Extensions vCloud

Retrieving vCloud Director VM Hard Disk size

I was asked recently if we were able to retrieve the disk space of a VM in vCloud Director through PowerCLI, on checking this I found that it is not currently part of the CIVM object and also there is currently no Get-HardDisk cmdlet equivalent like in the vSphere snapin.

After looking through the REST API Reference Documentation –> User Operations I found an entry for the VM VirtualHardwareSection  and specifically the disks which can be found as can be seen here: GET /vApp/{id}/virtualHardwareSection/disks

The virtualhardwaresection is easily accessed via PowerCLI using the extensiondata property which allows access to the back end API, I could then find my disk properties by filtering on the description of Hard Disk as in the example below:

(Get-VM MyCloudVM).ExtensionData.getvirtualhardwaresection().Item | Where { $_.Description -like “Hard Disk”}

Now I had the hard disk I noticed that part of the information was the capacity as highlighted below:image

With this information I could then find the capacity of the disk and add the information I needed into more of a friendly PowerShell property to the Hard Disk object.

So tying this all back together we could easily use the .ExtensionData reference to create our own Advanced PowerShell function to return the hard disk information for any CIVM.


The following shows an example of how to use this new function and the output, this of course can also be used to export into CSV/HTML/Text or any other format PowerShell can be used with, it is also great for reporting on where the disk space in your cloud is being used!


The Code

Function Get-CIVMHardDisk {
Param (
Process {
$AllHDD = $CIVM.ExtensionData.getvirtualhardwaresection().Item | Where { $_.Description -like “Hard Disk”}
$HDInfo = @()
Foreach ($HD in $AllHDD) {
$HD | Add-Member -MemberType NoteProperty -Name “Capacity” -Value $HD.HostResource[0].AnyAttr[0].”#text”
$HD | Add-Member -MemberType NoteProperty -Name “VMName” -Value $CIVM.Name
$HDInfo += $HD



38 comments have been added so far

  1. Cheers!
    Just what i needed.

    Get-CIVM | where name -Like “NL-AM*” | Get-CIVMHardDisk | select VMName, ElementName, Capacity

  2. I know it’s an old post, but still very useful – thanks Alan.

    I had a recent requirement to extend this functionality for a customer who consumes multiple different storage tiers from our cloud platform and wanted to see not just which disks were attached to each VM, but which storage tiers these were on too (since vCloud Director 8.xx and later allow these to be different). I’ve written up how I did this at: http://kiwicloud.ninja/2017/01/detailed-vm-storage-information-in-vcloud-director/ in case this is of use to anyone else.

  3. Vital keto is a concept that has been widely discussed in the health and fitness industry over the past few years. It is about how you can ‘get your body into ketosis’ (which is much higher than the normal ‘keto mode’). It is the body’s own version of ketosis and actually makes your body burn more fat and more calories (which makes sense, since you can literally burn more calories in this state – much like when you’re exercising) so you lose weight. It is simply the body’s way of saying “hey, I’m really in shape and want to stay that way! Let me eat all the candy and cookies and go get exercise and lose this weight quickly!

  4. Laser tattoo removal is a way to remove a piece of artwork that you just can’t take off your skin. It is not in any way like cosmetic surgery and therefore can cost hundreds of dollars. When you do a quick search on the internet you will find lots of reviews, but many do not say how the experience was for them. By doing your research, you will be able to save yourself a lot of time and money by finding the best laser tattoo removal clinic for you. With the right laser tattoo removal clinic, you will be able to get rid of those nasty tattoos with ease. Cascade medical spa is best option for you for this.

  5. Throughout the years there have been numerous incredible dark pioneers News Makers. This reality has made me keep thinking about whether there was one predominant attribute that isolated them from others. In light of that question, I chose to track down the prevailing characteristic that was available in some of America’s top Black News Makers over a wide span of time after which I put those attributes into a test so individuals can check whether they gangs these equivalent News Maker qualities. The test is situated at Blacknews4us.com however don’t go yet first read the article.

  6. Novid19 is a nourishing nutritional supplement formulated to add natural energy to your daily routine. The ingredients list has been carefully curated to provide a boost to any daily regimen

  7. A review of the Kratom from Kures Apothecary is a blog that provides people with the best prices on OPMS Kratom—a well-known and widely used kratom brand. The blog also offers reviews on other products made with kratom, such as capsules and powder. There are numerous strains of kratom with different effects. For example, red vein thai is known for its stimulating properties, while green malay is known for its calming effect.

Leave a Reply

Your email address will not be published.