Skip to content

Commit 5e23286

Browse files
Dismount Fix
1 parent 64146ae commit 5e23286

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ComputeAdmin/AzureStack.ComputeAdmin.psm1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,12 @@ function New-Server2016VMImage {
481481
} catch {
482482
Write-Error -ErrorRecord $_ -ErrorAction Stop
483483
} finally {
484-
if (Test-Path -Path "$VHDDriveLetter`:\") {
485-
$VHDPath | Dismount-DiskImage
484+
$retryAttempts = 0;
485+
while ((Test-Path -Path "$VHDDriveLetter`:\") -and ($retryAttempts -lt 5)) {
486+
Write-Verbose -Message "Attempting to dismount the VHD..."
487+
Get-DiskImage -ImagePath $VHDPath | Dismount-DiskImage
488+
$retryAttempts = $retryAttempts+1;
489+
sleep 1
486490
}
487491
if ($IsoMount) {
488492
$IsoMount | Dismount-DiskImage

0 commit comments

Comments
 (0)