Resize Partition - PowerShell


Overview

The Resize-Partition command in PowerShell enables you to modify the size of existing partitions on a physical or virtual disk. It’s particularly useful in disk management tasks like extending or shrinking partitions to optimize storage utilization.

Syntax

Resize-Partition -DriveLetter <string> -Size <Int64>

Options/Flags

| Option | Description | Default Value |
|—|—|—|
| -DriveLetter | Specifies the drive letter of the partition to resize. | None |
| -Size | Sets the new size of the partition in bytes. | None |

Examples

Example 1: Shrink a partition

Resize-Partition -DriveLetter C -Size 200GB

Example 2: Extend a partition to fill the disk

Resize-Partition -DriveLetter C -Size -1

Common Issues

  • Insufficient space: Ensure the disk has enough free space to accommodate the partition resizing.
  • Partition dependencies: Resizing a partition may impact other dependent partitions. Proceed with caution.

Integration

Resize-Partition can be integrated with other PowerShell commands, such as:

  • Get-Partition to retrieve partition information.
  • Set-Partition to adjust partition properties.
  • New-Partition
  • Set-Partition
  • Wipe-Partition