mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-05-28 04:36:05 -04:00
Add powershell script for attaching a harddisk to a guest
This commit is contained in:
parent
09bd28048e
commit
26e5cf1d02
1 changed files with 19 additions and 0 deletions
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…
Reference in a new issue