Thanks for the response. I bought the book, and I just received it today. I was wondering... Is there a way to get the drive letter using the get-vmdiskmapping cmdlet? I tried to use the script in the book and it worked, but I can't figure out how to get the drive letter. Any help would be appreciated!
Thanks for buying the book, I hope you will enjoy it.
I assume you are referring to the script in Listin 7.4 ?
Did you get the listing from the website ?
I'm afraid we don't provide the drive letters in that script.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
I haven't had much time to read it, but I can see it will be very useful! but to answer your questions, yes, I copied the script from the website. So, is it possible to get the drive letter using that script? because I don't seem to find a way to do it. Please let me know.
No, I'm afraid we don't provide the drive letter in that script.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
So is it even possible to do it? I haven't found a way to get the drive letters to match SCSI Ports higher than 0 (1:0, 2:0, 3:0). I have tried many things, but none of them seem to work, and I am starting to realize that there isn't a way to do it. Please let me know if you have any ideas.
For now, I have no clue how this could be done.
Which doesn't mean it isn't possible of course
I'll put it on my list of things to investigate.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
I will keep looking, and if I find a solution I will post it here... If you find a solution before I do please let me know. I appreciate your help!
FYI, a long while back I reached a dead-end trying to match Win32_LogicalDiskToPartition (Antecedent) with Win32_DiskDriveToDiskPartition (dependentDeviceID). They don't seem to match up (for joins), the AntecedentDeviceID will be 'PHYSICALDRIVE0' for the first disk on each virtual scsi controller. Scripts will report >=2 C: drives when you use multilpe virtual scsi controllers.
I'd love to see something that can reliably match disks on multilpe virtual controllers.
I found this script which uses WMI from within a machine, or can be used remotely (you'll need to enable remoting for those servers)
Seems to do exactly what you need.
It doesn't reference the vSphere PowerCli in any way.
I believe it is possible to "mashup" Get-DiskScsiLun (from http://rvdnieuwendijk.com/2012/05/29/powershell-function-to-get-disk-scsi-lun-number/) with the script by Arnim van Lieshout (from http://www.van-lieshout.com/2009/12/match-vm-and-windows-harddisks-using-powercli/) in order to achieve this. I have it working but we only have 1 scsi controller per system, and our logical drive : partition ratio is always 1:1 also so I don't know if it would work against all setups. The type of object returned contains information as so:
SCSIController : SCSI controller 0 DiskName : Hard disk 3 SCSI_Id : 0:4 DiskFile : [vc01_vfi01_vol01] serverA/serverA3_4-000001.vmdk DiskSize : 2 WindowsDisk : Disk 2 WindowsDriveLetter : T:
Care to share your version?
The ones I have seen are good, but they dont seem to provide the windows disk number.
Sure @Mike_Yazbeck, Funnily enough, my brother is just working on taking the code and porting it to a new version of the web front end we use to run PowerShell scripts, so he's been enjoying the complexity of it. I'll put the required bits together and improve the error handling and get back to you shortly.
Although I do like both scripts from Robert and Arnim, I found that with Arnim's script, I ran into issues when specifying /format:csv which then led me to this fix:
Having said that, I still never got the logical disk number in windows to populate. Having said that I have seen various methods to populate everything but using WMI.
Personally im not a big fan of running WMIC using invoke script... I can understand why its used, but if someone has misconfigured servers in the environment, you dont want to have to retrospectively fix those servers, I would rather a script that worked out of the box which is why I lean towards Robert's script.
Plus it has the added bonus of populating the drive letter which I imagine most people would want
Although his sample output looks good, its not entirely obvious which correlates to what
Im looking forward to your juicy script.
Thanks for your support and your efforts