Get-Partition

Get-Partition

Returns a list of all partition objects visible on all disks, or optionally a filtered list using specified parameters.

Syntax

Parameter Set: ByNumber
Get-Partition [[-DiskNumber] <UInt32[]> ] [[-PartitionNumber] <UInt32[]> ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Parameter Set: ByDisk
Get-Partition [-AsJob] [-CimSession <CimSession[]> ] [-Disk <CimInstance> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Parameter Set: ByDriveLetter
Get-Partition [-AsJob] [-CimSession <CimSession[]> ] [-DriveLetter <Char[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Parameter Set: ById
Get-Partition [-AsJob] [-CimSession <CimSession[]> ] [-DiskId <String[]> ] [-Offset <UInt64[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Parameter Set: ByVolume
Get-Partition [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [-Volume <CimInstance> ] [ <CommonParameters>]

Detailed Description

The Get-Partition cmdlet returns one or more Partition objects depending on the specified criteria. This cmdlet will return a Volume object or a set of Volume objects given parameters to be used to uniquely identify a volume, or parameters to identify a set of volumes that meet the given set of criteria.

Parameters

-AsJob

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<CimSession[]>

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Aliases

Session

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Disk<CimInstance>

Accepts a Disk object as input. The Disk CIM object is exposed by the Get-Disk cmdlet.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-DiskId<String[]>

Specifies an ID used to identify a disk in the system.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DiskNumber<UInt32[]>

Specifies the number of the disk.

Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DriveLetter<Char[]>

Specifies a letter used to identify a drive or volume in the system. Specifically the drive on which the partition resides.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Offset<UInt64[]>

Specifies the starting offset, in bytes.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-PartitionNumber<UInt32[]>

Specifies the number of the partition.

Aliases

Number

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Volume<CimInstance>

Accepts a Volume object as input. The Volume CIM object is exposed by the Get-Volume cmdlet.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Disk

    The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_VirtualDisk

    The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Volume

    The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Partitions

    The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

Examples

EXAMPLE 1

This example return all partitions, on all disks.

PS C:\> Get-Partition

EXAMPLE 2

This example return all partitions on disk 5.

PS C:\> Get-Partition -DiskNumber 5

EXAMPLE 3

This example partition associated with the volume for drive letter C.

PS C:\> Get-Partition -DriveLetter C

EXAMPLE 4

This example returns only the basic partitions on all disks.

PS C:\> Get-Partition | Where-Object –FilterScript {$_.Type -Eq "Basic"}

Get-Disk

Get-Volume

Where-Object