Powershell to Resize/Extend Partition on Windows Server 2019

by John, Published on: March 10, 2020

This article introduces how to resize partition with powershell in Windows Server 2019, run powershell to shrink and extend partition volume without losing data.

PowerShell is a task-based command-line shell and scripting language built on .NET. PowerShell helps system administrators and power-users rapidly automate tasks that manage operating systems and processes. PowerShell commands let you manage computers from the command line. It includes a rich expression parser and a fully developed scripting language.

PowerShell can do so much tasks, then is it possible to resize partition with PowerShell? The answer is yes. In this article, I'll show you how to shrink and extend partition with PowerShell in Windows Server 2019.

How to shrink partition volume with PowerShell

Firstly, press Windows and X on the keyboard, then select Windows PowerShell (Admin) in the list.

Steps to shrink partition/volume with PowerShell in Windows Server 2019:

  1. Type diskpart in the command window and press Enter.
  2. Type list volume and press Enter, then you'll see all partitions in a list with some information.
  3. Type select volume D and press Enter. (D is the number or drive letter of the partition that you want to shrink.)
  4. Type shrink desired=YY. (YY is a value in but without MB)

Immediately, PowerShell reports this drive is successfully shrunk.

Powershell shrink

How to extend volume partition with PowerShell

If you want to extend partition with PowerShell, it is not so easy as shrinking. Firstly, you have to delete the right contiguous partition. If there's no or you cannot delete this partition, PowerShell cannot help you extend partition.

Steps to extend partition with Powershell in Windows Server 2019:

  1. Type diskpart in PowerShell command window and press Enter.
  2. Type select volume D and press Enter. (D is the number or drive letter of the right contiguous partition.)
  3. Type delete volume and press Enter.
  4. Type select volume C and press Enter. (C is the number or drive letter of the partition that you want to expand.
  5. Type extend and press Enter.

Run list volume again, as you see, C drive is extended from 40GB to 110GB.

Extend successfully

Powershell extend

Limitations to resize partition with PowerShell

After running diskpart in PowerShell, run help shrink and help extend, you'll see the restrictions of PowerShell to resize partition in Windows Server 2019.

Shrink limitations

Extend limitations

Limitations to resize partition volume with PowerShell on Windows Server 2019:

If you run Windows Server 2019 Disk Management to resize partition, there are the same restrictions, so you'd better run server partition software.

Download NIUBI Partition Editor and follow the steps in the video to shrink and extend partition.

How to extend system partition by shrinking data volume(s):

Video Server 2019

How to extend D drive by shrinking other data volume or system partition:

Video Server 2019

Besides shrinking and extending partitions, it helps you do many other disk and partition operations.