diff --git a/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 b/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 new file mode 100644 index 000000000..5f23e932e --- /dev/null +++ b/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 @@ -0,0 +1,19 @@ +#Requires -Modules VagrantMessages + +param( + [Parameter(Mandatory=$true)] + [string]$VmId, + [string]$ControllerType, + [string]$ControllerNumber, + [string]$ControllerLocation, + [Parameter(Mandatory=$true)] + [string]$DiskFilePath +) + +try { + $vm = Hyper-V\Get-VM -Id $VmId + Hyper-V\Add-VMHardDiskDrive -VMName $vm -ControllerType $ControllerType -ControllerNumber $ControllerNumber -ControllerLocation $ControllerLocation -Path $DiskFilePath +} catch { + Write-ErrorMessage "Failed to attach disk ${DiskFilePath} to VM ${vm}: ${PSItem}" + exit 1 +}