In my work environment when we use MS SQL, so we have to build failover clusters. This means the use of RDM (Raw Device Mappings) LUNs. So you have to connect the RDM LUNs to the first system and them connected them to the second system using the disk file names. This is not a big deal, but it is nice to speed this process of mapping the drive on the second system, and cut and paste is your friend.
$VM = "VMNameHere" Get-vm $VM | Get-HardDisk | Where {$_.Disktype -eq "RawPhysical"} | Select CapacityGB, Filename
This will get you the basic information that is needed to map the drives on the second node of the cluster, but it would be nice to get some additional information.
$VM = "VMNameHere" $VmView = Get-View -ViewType VirtualMachine -Filter @{"Name" = $VM} foreach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "SCSI Controller"})) { foreach ($VirtualDiskDevice in ($VMView.Config.Hardware.Device | where {$_.ControllerKey -eq $VirtualSCSIController.Key})) { Get-VM $VM | Select Name, @{N="DiskName";E={$VirtualDiskDevice.DeviceInfo.Label}}, @{N="CanonicalName";E={(Get-VM $VM | Get-Harddisk -Name ($VirtualDiskDevice.DeviceInfo.Label)).ScsiCanonicalName}}, @{N="SCSI_Id";E={"$($VirtualSCSIController.BusNumber) : $($VirtualDiskDevice.UnitNumber)"}}, @{N="DiskFile";E={$VirtualDiskDevice.Backing.FileName}}, @{N="DiskSize(GB)";E={$VirtualDiskDevice.CapacityInKB * 1KB / 1GB}} } }
With this it will get the name of the server you are working with, the disk file name, SCSI canonical name, SCSI ID, disk file name, and the disk size. With this output, you can easily cut and paste the disk file name into the second node without having to browse the datastore to find the VMDK pointer file to attach. Also have the SCSI node ID so you make make sure that they match on both nodes.
-Stuart
Hi Stuart, This is a useful script. May I ask how can I save this to a csv file thanks
Hello Jay,
I glad that you found this useful. Below is the modified script that will output the results to a CSV file.
Hi Stuart,
Thank you for the script. I tried this script by adding &{ } and I was able to import the output to csv. My question is how if i want to get details of multiple servers from list using Get-Content serverlist.txt
Update i manage to solve it getting from server list. New question is how can we include the VMs advance settings to get the scsiID settings if they are ctkenabled and sharing as multiwriter. Thanks
Nah it didnt worked on get the first server on the list 🙁
Just change the lines:
to the following:
Unfortunately, The canonical name output fails so the script doesn’t show you the output of the lun Id as consequence.
how can it be fix?
Pepe,
Sorry to hear that this script isn’t working for you. Would you provide the error message from the script?
-Stuart