Merge pull request #8811 from benjamb/size-check

Fix Hyper-V compacted disk size comparison
This commit is contained in:
Megan Marsh 2020-03-02 10:44:35 -08:00 committed by GitHub
commit 5eead20ae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -872,9 +872,9 @@ if ($disks.Length -eq 0) {
foreach ($disk in $disks) {
Write-Output "Compacting disk: $(Split-Path $disk -leaf)"
$sizeBefore = $disk.Length
$sizeBefore = (Get-Item -Path $disk).Length
Optimize-VHD -Path $disk -Mode Full
$sizeAfter = $disk.Length
$sizeAfter = (Get-Item -Path $disk).Length
# Calculate the percentage change in disk size
if ($sizeAfter -gt 0) { # Protect against division by zero