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
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: GitHub - Monte-Hazboun/cVHDtoVMConnector: DSC resources to connect Hyper-V VHDs to VMs
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”
}
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