Author Posts

July 4, 2016 at 6:34 pm

Hello,

I'm looking for a way to attach VHD(x) files as data disks to Hyper-V VMs with DSC. I have a DSC configuration to create the VM with the xVMHyperv resource and to create the VHD(x) files with the xVHD resource. But now how can I attach such a virtual hard disk file let's say to port 2 of SCSI controller 1 as a data disk within the DSC configuration?

I know there are cmdlets like Add-VMHardDiskDrive for this purpose. But how to do that in a DSC configuration? Are there any resource implementations out there? Or have I to write my own DSC resource for that?

Thank you for any hint,
Gerhard

July 5, 2016 at 4:40 am

Hi Gerhard,

I ended up having to create my own resource to do this as the xHyper-V DSC resources only seems to support having one drive attached to a VM on creation.

You can find the resource here: https://github.com/Monte-Hazboun/cVHDtoVMConnector

You can call it in your configuration like so:

cVHDtoVMConnector ServerEDrive {
VMName = "Server"
VHDPath = [Path to VHD]
ControllerType = "SCSI"
ControllerNumber = 0
ControllerLocation = 1
Ensure = "Present"
DependsOn = "[xVHD]VHDcreationresource"
}

  • This reply was modified 2 years, 1 month ago by  Monte Hazboun.

July 5, 2016 at 7:30 pm

Hi Monte,

thank you very much for your quick answer. That's exactly what I was looking for. I tried your resource and it did its job. Great!
Once more thank you for your help.

Gerhard