Skip to content

Commit 64146ae

Browse files
Fixed VHD mounting issue
1 parent 91fea3a commit 64146ae

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

ComputeAdmin/AzureStack.ComputeAdmin.psm1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,15 @@ function New-Server2016VMImage {
440440
}
441441
Write-Verbose -Message "Preparing VHD"
442442

443-
$VHDDriveLetter = (Mount-VHD -Path $VHDPath -Passthru | `
444-
get-disk -number {$_.DiskNumber} | `
443+
Mount-DiskImage -ImagePath $VHDPath -Passthru
444+
$disknum = (Get-DiskImage -ImagePath $VHDPath).Number
445+
$VHDDriveLetter = (get-disk -number $disknum| `
445446
Initialize-Disk -PartitionStyle MBR -PassThru | `
446-
New-Partition -UseMaximumSize -AssignDriveLetter:$False -MbrType IFS | `
447+
New-Partition -UseMaximumSize -AssignDriveLetter:$False -IsActive:$true | `
447448
Format-Volume -Confirm:$false -FileSystem NTFS -force | `
448449
get-partition | `
449450
Add-PartitionAccessPath -AssignDriveLetter -PassThru | `
450-
get-volume).DriveLetter
451+
get-volume).DriveLetter
451452

452453
Write-Verbose -Message "VHD is mounted at drive letter: $VHDDriveLetter"
453454

0 commit comments

Comments
 (0)