This project is read-only.

Reading adapter types from VMDKs and setting on New-VirtualDisk

Nov 14, 2011 at 9:59 PM


I have downloaded and implemented the powershell implementation of DiscUtil and have found it to be very powerful.  I am trying to solve an issue, however.  I have a directory full of VMDK files (and their coresponding xxx-flat.vmdk files).  I am looping through those files and also through a second directory, if I find that the second directory doesn't already have a clone of the first, then I create, initialize, create a volume, and format a new disk to keep on the second directory.  This is all working great, however, I wonder if there is a way to determine the adaptertype of the first disk before making the second, and then specifying that adapter type in the new disk.   I am using the following command to mount the first file (only to get the disksize so that I can set it correctly on the new disk)

        New-PSDrive newdrive -PSProvider virtualdisk -Root $b.fullname
        #Get byte size of mounted VMDK pagefile
        $b_stats=dir newdrive:

Then I am using the next command to create the new disk with the correct sizing:

       New-VirtualDisk $b.fullname.replace($ProdPageFilePath, $DRPageFilePath) -Type VMDK-vmfsfixed -Size $b_stats.length

Somewhere in this process, I would hope to be able to check the adapter type of "newdrive" in the first block, and then specify it in the second New-VirtualDisk block.  Please help if you can.  Thanks in advance!


Nov 16, 2011 at 12:28 AM


It's not currently possible to do that, but I'll copy this to a work item as something to add.



Nov 16, 2011 at 12:28 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Nov 16, 2011 at 1:55 AM

Thanks Ken.  I was able to read out the adapter type from the existing VMDK file and then just do a simple .replace on the new VMDK to make the adapters match.  I am now having a hard time creating a disk of the same size.  I currently do a mount using the same method above, but when a I read back the $b_stats.length I think that is telling me the size of the volume and not the disk itself.  So when I go to initialize and format the new volume, I can't make it exactly the same since since I didn't make the disk large enough to begin with.  What I would really like to accomplish using this toolset is creating an exact duplicate of the source VMDK (disk size/type, partition table, etc) only empty.  So a clone without the data.  Is there a path that might lead me this way?  Basically the disk is drive P: on the source VM, but when I re-create the disk using method, it gets relabeled to E: or something else since windows doesn't recognize it as the same disk.  Thanks for any help!