I recently took a new position in my company where I am the lead design engineer for a particularly complex software. It just so happens that this software also houses our medical records, so deploying it correctly is kinda important!
We have many instances of this setup deployed and each instance comprises 19 VMs. Across those instances, the disk layout should be exactly the same for a given server. After a cursory check, I noticed one of our pagefiles was not on the proper datastores and we were virtually out of free capacity to expand. Rather than sit idle and wait for the next revelation to come, I looked for a script or some other report that would tell me most anything I would want to know about the storage behind my Windows logical disk for the VMs. Finding nothing that really fit what I was after, I took a stab at it myself.
I've attached what I have come up with thusfar but would love ideas on how to improve it. Forgive some of my syntax as I traditionally have only done relatively simple scripts. I found the info I needed resided in three distinct areas: Windows OS (attained via WMI queries), VM and datastore information (PowerCLI). Doing the relationship work for this was the real challenge, that and using WMI via PS for the first time. Who ever would have thought it would take four queries to get from C: to the corresponding SCSIPort and SCSITargetID? Beyond that, simple matches to the VM to find what HDD the drive corresponds to and so on with the datastore info. I really like having the NAA ID output with this as well so I can have conversations with our storage team and address the disk in their terms.
Output provides the following on a per drive level:
Windows drive letter
Windows drive label
VM hard disk name
VM hard disk capacity
VM VML ID for RDMs
VM RDM device name / NAA
VM hard disk type
Datastore device name / NAA
Datastore free MB
Datastore total MB
Datastore block size MB
Thanks in advance for any suggestions on how to improve this!
A quick remark, the logic doesn't seem to take into account that a disk can have multiple partitions.
In that case the following line will not work and the Windows drive information will be lost.
because $Level1o is an array.
This can be the case with some OS that place a system or diagnostic partition on the first physical disk.