vagrant/plugins/providers/hyperv/scripts/resize_disk_drive.ps1

22 lines
497 B
PowerShell
Raw Normal View History

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
2020-03-31 16:30:45 -04:00
#Requires -Modules VagrantMessages
param(
[Parameter(Mandatory=$true)]
[string]$VmId,
[Parameter(Mandatory=$true)]
2020-04-13 17:57:01 -04:00
[string]$DiskFilePath,
2020-03-31 16:30:45 -04:00
[Parameter(Mandatory=$true)]
[UInt64]$DiskSize
2020-03-31 16:30:45 -04:00
)
try {
$VM = Hyper-V\Get-VM -Id $VmId
Hyper-V\Resize-VHD -Path $DiskFilePath -SizeBytes $DiskSize
} catch {
Write-ErrorMessage "Failed to resize disk ${DiskFilePath} for VM ${VM}: ${PSItem}"
exit 1
}