Powershell Shrink/Extend Partition in Windows Server 2016

by John, Updated on: July 28, 2022

Many administrators want to resize Windows server partition after running the server for a period of time. Some people want to shrink a large partition to create new volume, some people want to extend C drive when it is running out of space. To repartition hard drive in Windows server, you may try Powershell if you don't want to use any software. This article introduces how to shrink and extend partition with powershell in Windows Server 2016/2019/2022, the shortages of Powershell and better way to resize server partition with safe software.

How to shrink partition with powershell in Server 2016/2019/2022

  1. Press Windows and R together on the keyboard to open Run, type powershell and press Enter.
  2. Type diskpart and press Enter in pop-up Windows PowerShell window.
  3. Type list volume and press Enter, then you'll see all single partitions with some parameters.
  4. Type select volume D and press Enter. (D is driver letter or number of the partition that you want to shrink.)
  5. Type shrink desired=20480 and press Enter. (20480 is the amount of free space to shrink in MBR, maximum amount will be used if you did not specify a value.)

In a short time, PowerShell reports that Diskpart successfully shrunk the volume by 20GB. Type list volume again, my D: drive is shrunk from 70GB to 50GB.

PowerShell shrink

Shrunk done

How to extend partition with PowerShell in Server 2016/2019/2022

Before extending volume with PowerShell, you must delete its contiguous partition on the right. If there's no right adjacent volume or you cannot delete it, you cannot extend volume with powershell in Windows Server 2016/2019/2022.

You cannot extend a partition by shrinking any other one. If you extend C: drive with powershell after shrinking D, you'll receive Virtual Disk Service error: The size of the extend is less than the minimum.

Steps to extend partition C with powershell in Windows Server 2016/2019/2022:

  1. Transfer all files in the right contiguous partition D: (in some server is E:) to other place.
  2. Type diskpart and press Enter in PowerShell window.
  3. (optional) Type list volume and press Enter.
  4. Type select volume D and press Enter.
  5. Type delete volume and press Enter.
  6. Type select volume C and press Enter.
  7. Type extend and press Enter.

In a short time, my system C drive is increased from 40GB to 110GB. (There's 20GB Unallocated space behind D drive, this type of space won't be listed.)

Powershell extend

Extend complete

Better way to resize partition in Windows Server 2016

There are many shortages while resizing partition with powershell in Server 2016/2019/2022, for example:

  1. Only NTFS partitions can be shrunk and extended, FAT32 and any other types are not supported.
  2. Unallocated space can only be generated on the right while shrinking partition.
  3. If there are some "unmovable" files in a partition, powershell can only shrink little free space although there's large amount.
  4. Unallocated space can only be used to create new volume, it cannot be moved or extended to other partitions.
  5. Any operations will be executed immediately.

With NIUBI Partition Editor, there are no such limitations. You can make Unallocated space on either left or right when shrinking NTFS and FAT32 partition. Extend partition with contiguous or non-adjacent Unallocated space on the same disk.

Download NIUBI Partition Editor and follow the steps in the video to shrink and extend volume in Windows 2016 server.

How to extend C: drive by shrinking other volume:

Video guide

How to extend D: drive by shrinking other volume:

Video guide

  • If you want to shrink partition and extend another non-adjacent volume, there's an additional step to move Unallocated space.
  • Steps are the same no matter you run physical server with SSD, HDD, RAID or virtual server in VMware/Hyper-V.
  • If there's no available free space in a disk, you can clone disk to a larger one or move a partition to another disk. When clone disk, you can extend partition with extra disk space.

Better than other software, NIUBI Partition Editor has innovative technologies to protect system and data.

Besides shrinking, extending, moving and copying disk partitions, NIUBI Partition Editor helps merge, convert, defrag, wipe, optimze, hide partition, scan bad sectors and much more.