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.
Hugo
7 Responses to Add RDM Size info to VI Client using Powershell
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





[...] his article for the script and the complete blogpost. Don’t forget to download the updated versions of [...]
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
@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
[...] 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 [...]
[...] ссылка на пост Хуго Питерса (Hugo Peeters) о скрипте, который добавляет информацию о размере RDM в VI-клиент с помощью P…. Мне понравилось смотреть на скрипты других людей – [...]
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
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