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.

Hugo

»crosslinked«

Tagged with:
 

7 Responses to Add RDM Size info to VI Client using Powershell

  1. [...] his article for the script and the complete blogpost. Don’t forget to download the updated versions of [...]

  2. Jeffrey Snover says:

    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: http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

  3. admin says:

    @Jeffrey Snover
    Hey Jeffrey,
    Thanks!
    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 ;)
    Hugo

  4. [...] not ready to recommend it yet BUT the very first item on the bullet was from depping with a link to a blog post by  Hugo Peeters about script that adds RDM size info to a VI client using ….  I love looking at other peoples scripts – it gives me a view into how they think about the [...]

  5. Anonymous says:

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

  6. Sylvain says:

    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

  7. David says:

    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
    or
    Cluster => Foldername => Subfolder => vm

    Hope you know an easy way to achieve this.

    Cheers,

    David

Leave a Reply