Add RDM Size info to VI Client using Powershell

I have had a lot of comments on my sample scripts that add information to the VI Client using Custom Fields. I did have to resolve some issues with the scripts, so I have updated the scripts in the original post here. Be sure to refresh your browser to get the latest versions.

In the VMware VI Toolkit Communities, a request was made for a similar script that adds the total size of all Raw Device Mappings (RDMs) on a VM to a Custom Field in the VI Client. The difference between this sample script and the ones I showed you earlier, is that the information is now pulled from $VM and not from $VMView. So I pulled the Get-View command inside the loop and here’s the result:

add-vmrdmsize (rename to .ps1)

Let me know if you can’t get it to work.


7 thoughts on “Add RDM Size info to VI Client using Powershell

  1. Howdy Hugo!

    That is a nice readable script. I thought I would make one suggestion that I’ve started doing more and more with my scripts. You have the following:

    $VMs = Get-VM
    ForEach ($VM in $VMs)

    Lately I’ve been collapsing that into a single line because I think it is more readable/maintainable (and I don’t have to think up a good variable name!). It would be:

    ForEach ($VM in Get-VM)

    Jeffrey Snover [MSFT]
    Windows Management Partner Architect
    Visit the Windows PowerShell Team blog at:
    Visit the Windows PowerShell ScriptCenter at:

  2. @Jeffrey Snover
    Hey Jeffrey,
    I do tend to use that technique when that part of the script is inside a loop, so that I don’t have to Clear-Variable the extra variable. At other times, when the first line needs an additional pipe to Where-Object, I often keep them on two separate lines for readability.
    I write my scripts mostly off the top of my head, so that’s probably why I sometimes create to much variables. I need to look them over more often when they are done to consolidate some of the clutter into single lines.
    Thanks for the tip! And I must say it’s an honor to have you on my blog 😉

  3. […] ссылка на пост Хуго Питерса (Hugo Peeters) о скрипте, который добавляет информацию о размере RDM в VI-клиент с помощью P…. Мне понравилось смотреть на скрипты других людей – […]

  4. Hello,
    It’s doesn’t work for me. The return size for the RDM disk is not right… do you have this problem ?

    Thanks in advance

  5. Hi Hugo,

    Nice script, helps me a lot for my disk usage reports.

    I don’t know if you do a script on demand ;-), but I’m looking for a PS script that puts the foldername where my VM is situated as an attribute.

    The reason why I need this is because I will recreate my clusters and otherwise I will lose all my foldernames where Ive’ put them.

    The logic we use is
    Cluster => Foldername => vm
    Cluster => Foldername => Subfolder => vm

    Hope you know an easy way to achieve this.



Leave a Reply