Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Set-Partition

Set-Partition

storagecmdlets.cdxml

Synopsis

Sets attributes of a partition, such as active, read-only, and offline states.

Syntax

Set-Partition [-DiskNumber] [-PartitionNumber] [-AsJob] [-CimSession] [-IsActive] [-IsHidden] [-IsReadOnly] [-NoDefaultDriveLetter] [-ThrottleLimit] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsActive] [-IsHidden] [-IsReadOnly] [-NoDefaultDriveLetter] [-ThrottleLimit] [-InputObject] [<CommonParameters>]

Set-Partition [-DiskNumber] [-PartitionNumber] [-AsJob] [-CimSession] [-IsOffline] [-ThrottleLimit] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsActive] [-IsHidden] [-IsReadOnly] [-NoDefaultDriveLetter] [-ThrottleLimit] [-DiskId] [-Offset] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-NewDriveLetter] [-ThrottleLimit] [-DriveLetter] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-NewDriveLetter] [-ThrottleLimit] [-DiskId] [-Offset] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-NewDriveLetter] [-ThrottleLimit] [-InputObject] [<CommonParameters>]

Set-Partition [-DiskNumber] [-PartitionNumber] [-AsJob] [-CimSession] [-NewDriveLetter] [-ThrottleLimit] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsOffline] [-ThrottleLimit] [-DriveLetter] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsOffline] [-ThrottleLimit] [-DiskId] [-Offset] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsOffline] [-ThrottleLimit] [-InputObject] [<CommonParameters>]

Set-Partition [-AsJob] [-CimSession] [-IsActive] [-IsHidden] [-IsReadOnly] [-NoDefaultDriveLetter] [-ThrottleLimit] [-DriveLetter] [<CommonParameters>]

Detailed Description

The Set-Partition cmdlet sets the attributes of a partition, including active, read-only, hidden, offline, and the drive letter.

Parameters

-AsJob <SwitchParameter>

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShell® background jobs, see about_Jobs.

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

-DiskId <String>

Specifies the disk ID of the partition to modify.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-DiskNumber <UInt32>

Specifies the disk number of the partition to modify.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-DriveLetter <Char>

Specifies the drive letter of the partition to modify.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-InputObject <CimInstance[]>

Specifies the Partition object to modify. Enter a Partition CIM object. The Partition object is exposed by the Get-Partition cmdlet.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByValue)

Accept wildcard characters?

false

-IsActive <Boolean>

Specifies that the partition is marked as active and can be used to start the system. This parameter is only relevant for MBR disks.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-IsHidden <Boolean>

Specifies that the partition is hidden. As a result, the partition does not receive a drive letter, does not receive a volume GUID path, and does not host volume mount points. This ensures that applications such as disk defragmenter do not access the partition.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-IsOffline <Boolean>

Takes the partition offline until explicitly brought back online, or until an access path is added to the partition.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-IsReadOnly <Boolean>

Sets the partition to be read-only (IsReadOnly $true) or read-write (IsReadOnly $false).

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-NewDriveLetter <Char>

Specifies the new drive letter for the partition.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-NoDefaultDriveLetter <Boolean>

Specifies that the automatic assignment of a drive letter is disabled. This is only honored for GPT disks. This attribute is useful in storage area network (SAN) environments.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Offset <UInt64>

Specifies the partition's offset from the beginning of the disk, measured in bytes.

Aliases

None

Required?

true

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?

true

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

Input Type

Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Partition

Return Type

None

Notes

None

Examples

Example 1: Set the partition to read-only

This example makes partition Y read-only.

PS C:\> Set-Partition -DriveLetter Y -IsReadOnly $True

Example 2: Set an MBR partition to active

This example makes the MBR partition Y active.

PS C:\> Set-Partition -DriveLetter Y -IsActive $True

Example 3: Hide the partition

This example hides partition Y.

PS C:\> Set-Partition -DriveLetter Y -IsHidden $True

Example 4: Take the partition offline

This example takes the partition and volume offline.

PS C:\> Set-Partition -DriveLetter Y -IsOffline $True

Example 5: Change the drive letter

This example changes the drive letter from Y to Z.

PS C:\> Set-Partition -DriveLetter Y -NewDriveLetter Z

Online Version
Get-Partition
New-Partition