Functions/Resize-MyVHD.ps1


function Resize-MyVHD {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory)] [string] $Path,
        [Parameter(Mandatory)] [int] $NewSizeGB
    )

    if (!(Test-Path $Path)) {
        Write-Error "File does not exist"
        break
    }

    $VHD = Get-VHD $Path -ea 0
    if (!($VHD)) {
        Write-Error "File is not a VHD"
        break
    }

    # $VHD

    $SizeBytes = $NewSizeGB * 1024 * 1024 * 1024

    # $SizeBytes

    if($SizeBytes -gt $VHD.Size) {
        Resize-VHD $Path -SizeBytes $SizeBytes
    } else {
        Write-Warning "New size is smaller then the current size"
    }

}