vaguerent/plugins/providers/hyperv/scripts/attach_disk_drive.ps1
2020-06-30 14:22:41 -07:00

22 lines
726 B
PowerShell

#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
# Add logic to support missing params. Below is the simple case for attaching a disk
Hyper-V\Add-VMHardDiskDrive -VMName $VM -Path $DiskFilePath
} catch {
Write-ErrorMessage "Failed to attach disk ${DiskFilePath} to VM ${VM}: ${PSItem}"
exit 1
}