Skip to content

Commit 59dcc29

Browse files
authored
Add support for Generation 2 VMs
1 parent 9e4760f commit 59dcc29

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

articles/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ $sourceDiskName = <sourceDiskNameHere>
146146
$targetDiskName = <targetDiskNameHere>
147147
$targetRG = <targetResourceGroupHere>
148148
$targetLocate = <yourTargetLocationHere>
149+
$targetVmGeneration = "V1" # either V1 or V2
149150
#Expected value for OS is either "Windows" or "Linux"
150151
$targetOS = <yourOSTypeHere>
151152
152153
$sourceDisk = Get-AzDisk -ResourceGroupName $sourceRG -DiskName $sourceDiskName
153154
154155
# Adding the sizeInBytes with the 512 offset, and the -Upload flag
155-
$targetDiskconfig = New-AzDiskConfig -SkuName 'Standard_LRS' -osType $targetOS -UploadSizeInBytes $($sourceDisk.DiskSizeBytes+512) -Location $targetLocate -CreateOption 'Upload'
156+
$targetDiskconfig = New-AzDiskConfig -SkuName 'Standard_LRS' -osType $targetOS -UploadSizeInBytes $($sourceDisk.DiskSizeBytes+512) -Location $targetLocate -CreateOption 'Upload' -HyperVGeneration $targetVmGeneration
156157
157158
$targetDisk = New-AzDisk -ResourceGroupName $targetRG -DiskName $targetDiskName -Disk $targetDiskconfig
158159
@@ -171,4 +172,4 @@ Revoke-AzDiskAccess -ResourceGroupName $targetRG -DiskName $targetDiskName
171172

172173
Now that you've successfully uploaded a VHD to a managed disk, you can attach your disk to a VM and begin using it.
173174

174-
To learn how to attach a data disk to a VM, see our article on the subject: [Attach a data disk to a Windows VM with PowerShell](attach-disk-ps.md). To use the disk as the OS disk, see [Create a Windows VM from a specialized disk](create-vm-specialized.md#create-the-new-vm).
175+
To learn how to attach a data disk to a VM, see our article on the subject: [Attach a data disk to a Windows VM with PowerShell](attach-disk-ps.md). To use the disk as the OS disk, see [Create a Windows VM from a specialized disk](create-vm-specialized.md#create-the-new-vm).

0 commit comments

Comments
 (0)