Add powershell script for attaching a harddisk to a guest
This commit is contained in:
parent
09bd28048e
commit
26e5cf1d02
19
plugins/providers/hyperv/scripts/attach_disk_drive.ps1
Normal file
19
plugins/providers/hyperv/scripts/attach_disk_drive.ps1
Normal file
@ -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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user