如何使用 Powershell 在 Windows Azure 中增加 OS 磁盘的大小

How to increase size of OS disk in Windows Azure using Powershell

我想使用 Powershell 或任何其他工具增加 Windows Azure 中 OS 磁盘的大小。请帮助

问候 乌梅尔

调整 OS 驱动器的大小

在管理模式下打开 Powershell ISE 或 Powershell window,然后按照以下步骤操作:

  1. 在资源管理模式下登录您的 Microsoft Azure 帐户并select您的订阅如下:

    Login-AzureRmAccount Select-AzureRmSubscription –SubscriptionName 'my-subscription-name'

  2. 按如下方式设置您的资源组名称和 VM 名称:

    $rgName = 'my-resource-group-name' $vmName = 'my-vm-name'

  3. 按如下方式获取对您的 VM 的引用:

    $vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName

  4. 在调整磁盘大小之前停止 VM,如下所示:

    Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName

  5. 我们期待已久的时刻来了!将 OS 磁盘的大小设置为所需的值并按如下方式更新 VM:

    $vm.StorageProfile.OSDisk.DiskSizeGB = 1023 Update-AzureRmVM -ResourceGroupName $rgName -VM $vm

    The new size should be greater than the existing disk size. The maximum allowed is 1023 GB.

  6. 更新 VM 可能需要几秒钟。命令完成执行后,按如下方式重新启动 VM:

    Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName

就是这样!现在 RDP 进入虚拟机,打开计算机管理(或磁盘管理)并使用新分配的 space.

扩展驱动器

粘贴自:https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-expand-os-disk

我在 windows azure powershell 最新版本上使用以下命令完成了此操作。请注意旧版本的 powershell 不支持此命令。

Update-AzureDisk -DiskName [Disk-Name] -Label [DiskLabel]-ResizedSizeInGB 1020