Get Partition - PowerShell


Overview

Get-Partition retrieves information about partitions on local and remote disks. It displays details such as partition type, size, file system, and mount point. This command is useful for managing disk space, troubleshooting partition issues, and performing system analysis.

Syntax

Get-Partition [[-DriveLetter] <String>] [[-DeviceID] <String>] [-Path <String>]
[-DiskNumber <UInt32>] [[-DiskName] <String>] [[-VolumeLabel] <String>] [-VolumeID <Guid>]
[-MountPoint <String>] [[-MountPath] <String>] [-FileSystem <String>]
[-VolumeMountPoint <String>] [-FullInfo] [-DiskSize <UInt64>] [-GPT] [-MBR]
[-BIOSBootPartition] [[-Exclude] <String>] [[-Include] <String>]
[-SystemDrive] [-Hidden] [-ReadOnly] [-PageSize <UInt32>]
[-SnapShot] [-UnsnapShot] [-FriendlyName] [-Status] [-MountDriveLetter]
[-MountPathIsMapped] [-Type <String>] [-Component]
[-DynamicallyExpandSupported] [-Recoverable] [-BootDisk] [-Mirrored]
[-StripeSize <UInt32>] [-Index <UInt32>] [-AccessMask <UInt32>] [-Name <String>]

Options/Flags

  • -DriveLetter: Filters partitions by their drive letter.
  • -DeviceID: Filters partitions by their device ID.
  • -Path: Filters partitions by their full path.
  • -DiskNumber: Filters partitions by the disk number.
  • -DiskName: Filters partitions by the disk name.
  • -VolumeLabel: Filters partitions by their volume label.
  • -VolumeID: Filters partitions by their volume ID.
  • -MountPoint: Filters partitions by their mount point.
  • -MountPath: Filters partitions by their mount path.
  • -FileSystem: Filters partitions by their file system.
  • -VolumeMountPoint: Filters partitions by their volume mount point.
  • -FullInfo: Displays additional partition information.
  • -DiskSize: Filters partitions by their disk size.
  • -GPT: Filters partitions by GPT disk type.
  • -MBR: Filters partitions by MBR disk type.
  • -BIOSBootPartition: Filters partitions marked as BIOS boot partitions.
  • -Exclude: Excludes partitions matching the specified criteria from the results.
  • -Include: Includes only partitions matching the specified criteria in the results.
  • -SystemDrive: Filters partitions that are marked as system drives.
  • -Hidden: Filters partitions that are hidden.
  • -ReadOnly: Filters partitions that are read-only.
  • -PageSize: Specifies the page size used for retrieving partition information.
  • -SnapShot: Filters partitions that are snapshots.
  • -UnsnapShot: Filters partitions that are unsnapshots.
  • -FriendlyName: Displays the partition’s friendly name.
  • -Status: Displays the partition’s status.
  • -MountDriveLetter: Mounts partitions that do not have a drive letter.
  • -MountPathIsMapped: Indicates if the partition’s mount path is mapped.
  • -Type: Filters partitions by their type.
  • -Component: Filters partitions by their component type.
  • -DynamicallyExpandSupported: Indicates if the partition supports dynamic expansion.
  • -Recoverable: Indicates if the partition is recoverable.
  • -BootDisk: Indicates if the partition is a boot disk.
  • -Mirrored: Indicates if the partition is mirrored.
  • -StripeSize: Filters partitions by their stripe size.
  • -Index: Filters partitions by their index.
  • -AccessMask: Filters partitions by their access mask.
  • -Name: Filters partitions by their name.

Examples

Get all partitions on the local system:

Get-Partition

Get the partition with the drive letter “C:”:

Get-Partition -DriveLetter C

Get the partition on disk 1:

Get-Partition -DiskNumber 1

Get the partition with the volume label “Data”:

Get-Partition -VolumeLabel Data

Get full information about all partitions:

Get-Partition -FullInfo

Get the partition type and size for all partitions:

Get-Partition | Select Type, Size

Common Issues

  • Error: The parameter is incorrect: Verify the value of the parameter, ensuring it is valid according to the syntax.
  • Error: The partition does not exist: Check if the partition has been deleted or is not visible to the system.
  • Error: Access is denied: Run the command as an administrator to gain sufficient permissions.

Integration

Get-Partition can be combined with other PowerShell commands to perform advanced tasks. For example:

  • Get the disk usage for each partition:
Get-Partition | Get-Volume | Get-DiskUsage
  • Create a new partition:
New-Partition -DiskNumber 1 -Size 500MB -MountPoint "Data"
  • Format-Partition
  • Mount-Partition
  • Resize-Partition