Modifier

Partager via


New-Partition

Creates a new partition on an existing Disk object.

Syntax

ByNumber (Default)

New-Partition
    [-DiskNumber] <UInt32[]>
    [-Size <UInt64>]
    [-UseMaximumSize]
    [-Offset <UInt64>]
    [-Alignment <UInt32>]
    [-DriveLetter <Char>]
    [-AssignDriveLetter]
    [-MbrType <MbrType>]
    [-GptType <String>]
    [-IsHidden]
    [-IsActive]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]

ByUniqueId

New-Partition
    -DiskId <String[]>
    [-Size <UInt64>]
    [-UseMaximumSize]
    [-Offset <UInt64>]
    [-Alignment <UInt32>]
    [-DriveLetter <Char>]
    [-AssignDriveLetter]
    [-MbrType <MbrType>]
    [-GptType <String>]
    [-IsHidden]
    [-IsActive]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]

ByPath

New-Partition
    -DiskPath <String[]>
    [-Size <UInt64>]
    [-UseMaximumSize]
    [-Offset <UInt64>]
    [-Alignment <UInt32>]
    [-DriveLetter <Char>]
    [-AssignDriveLetter]
    [-MbrType <MbrType>]
    [-GptType <String>]
    [-IsHidden]
    [-IsActive]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]

InputObject (cdxml)

New-Partition
    -InputObject <CimInstance[]>
    [-Size <UInt64>]
    [-UseMaximumSize]
    [-Offset <UInt64>]
    [-Alignment <UInt32>]
    [-DriveLetter <Char>]
    [-AssignDriveLetter]
    [-MbrType <MbrType>]
    [-GptType <String>]
    [-IsHidden]
    [-IsActive]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]

Description

The New-Partition cmdlet creates a partition on a specified Disk object. Note: This cmdlet does not support creating dynamic volumes.

Examples

Example 1: Create a new partition on disk 1

PS C:\> New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter T

This example creates a new partition on disk 1 using the maximum available space and assigns a drive letter T.

Example 2: Get all RAW disks, initialize the disks, partition, and format them

PS C:\> Get-Disk | Where-Object PartitionStyle -Eq "RAW" | Initialize-Disk -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume

This example uses five cmdlets and the pipeline to get all disks, filter them for only RAW, unpartitioned disks, initialize the disks, partition the disks, and then to format them.

Example 3: Create a new EFI partition on GPT disk 2

PS C:\> New-Partition -DiskNumber 2 -Size 500MB -GptType "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}"

This example creates a new EFI partition on disk 2 with a size of 500 MB.

Example 4: Create a Windows/system partition on MBR disk 0

PS C:\> New-Partition -DiskNumber 0 -Size 100GB -MbrType IFS -IsActive

This example creates a new Windows/system partition on MBR disk 0 with a size of 100 GB.

Parameters

-Alignment

Specifies the alignment boundary in bytes.

Parameter properties

Type:UInt32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AssignDriveLetter

Assigns a drive letter to the new partition.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-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.

Parameter properties

Type:

CimSession[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:Session

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DiskId

Specifies the ID of the disk on which to create the partition.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:Id

Parameter sets

ByUniqueId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DiskNumber

Specifies an array of disk numbers.

Parameter properties

Type:

UInt32[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByNumber
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DiskPath

Specifies the path of the disk on which to create the partition.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByPath
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DriveLetter

Specifies the specific drive letter to assign to the new partition.

Parameter properties

Type:Char
Default value:None
Supports wildcards:False
DontShow:False
Aliases:NewDriveLetter

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-GptType

Specifies the type of GPT partition to create (by GUID). The format should be 32 digits separated by hyphens, enclosed in braces and quoted:

"{00000000-0000-0000-0000-000000000000}"

By default, the New-Partition cmdlet creates a basic GPT data partition.

The GUIDs of valid types are:

  • System Partition - "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}"
  • Microsoft Reserved - "{e3c9e316-0b5c-4db8-817d-f92df00215ae}"
  • Basic data - "{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}"
  • Microsoft Recovery - "{de94bba4-06d1-4d40-a16a-bfd50179d6ac}"

Parameter properties

Type:String
Default value:{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

Specifies the input object that is used in a pipeline command.

Parameter properties

Type:

CimInstance[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

InputObject (cdxml)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-IsActive

Marks the partition as active:

  • On a BIOS-based system, the active partition is the partition the system will boot to. This partition must be a primary partition.
  • On a Unified Extensible Firmware Interface (UEFI)-based system, this setting is not used. The system will always boot to the EFI System Partition (ESP). If Active is set for this partition type, it is ignored.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IsHidden

Creates a hidden partition.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-MbrType

Specifies the type of MBR partition to create.

Parameter properties

Type:MbrType
Default value:Huge
Accepted values:FAT12, FAT16, Extended, Huge, IFS, FAT32
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Offset

Specifies the starting offset, in bytes.

Parameter properties

Type:UInt64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Size

Specifies the size of the partition to create. If not specified, then the units will default to Bytes. The acceptable value for this parameter is a positive number followed by the one of the following unit values: Bytes, KB, MB, GB, or TB.

Parameter properties

Type:UInt64
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ThrottleLimit

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.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UseMaximumSize

Creates the largest possible partition on the specified disk.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

CimInstance

You can pipe a Disk object to the InputObject parameter.

Outputs

CimInstance

This cmdlet outputs an object that represents the newly created partition.

Notes

  • You can use either -AssignDriveLetter parameter or -DriveLetter parameter, but not both at the same time, while creating a new partition.
  • When used in Failover Cluster, cmdlets from the Storage module operate on cluster level (all servers in the cluster).