Set-Partition
Set-Partition
Sets attributes of a partition, such as active, read-only, and offline states.
Syntax
Parameter Set: ByNumberAttributes
Set-Partition [-DiskNumber] <UInt32> [-PartitionNumber] <UInt32> [-AsJob] [-CimSession <CimSession[]> ] [-IsActive <Boolean> ] [-IsHidden <Boolean> ] [-IsReadOnly <Boolean> ] [-NoDefaultDriveLetter <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByDriveLetter
Set-Partition -DriveLetter <Char> [-AsJob] [-CimSession <CimSession[]> ] [-IsOffline <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByDriveLetterAccessPath
Set-Partition -DriveLetter <Char> [-AsJob] [-CimSession <CimSession[]> ] [-NewDriveLetter <Char> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByDriveLetterAttributes
Set-Partition -DriveLetter <Char> [-AsJob] [-CimSession <CimSession[]> ] [-IsActive <Boolean> ] [-IsHidden <Boolean> ] [-IsReadOnly <Boolean> ] [-NoDefaultDriveLetter <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ById
Set-Partition -DiskId <String> -Offset <UInt64> [-AsJob] [-CimSession <CimSession[]> ] [-IsOffline <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByIdAccessPath
Set-Partition -DiskId <String> -Offset <UInt64> [-AsJob] [-CimSession <CimSession[]> ] [-NewDriveLetter <Char> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByIdAttributes
Set-Partition -DiskId <String> -Offset <UInt64> [-AsJob] [-CimSession <CimSession[]> ] [-IsActive <Boolean> ] [-IsHidden <Boolean> ] [-IsReadOnly <Boolean> ] [-NoDefaultDriveLetter <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByNumber
Set-Partition [-DiskNumber] <UInt32> [-PartitionNumber] <UInt32> [-AsJob] [-CimSession <CimSession[]> ] [-IsOffline <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByNumberAccessPath
Set-Partition [-DiskNumber] <UInt32> [-PartitionNumber] <UInt32> [-AsJob] [-CimSession <CimSession[]> ] [-NewDriveLetter <Char> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByObject
Set-Partition -InputObject <CimInstance[]> [-AsJob] [-CimSession <CimSession[]> ] [-IsOffline <Boolean> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByObjectAccessPath
Set-Partition -InputObject <CimInstance[]> [-AsJob] [-CimSession <CimSession[]> ] [-NewDriveLetter <Char> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]
Parameter Set: ByObjectAttributes
Set-Partition -InputObject <CimInstance[]> [-AsJob] [-CimSession <CimSession[]> ] [-IsActive <Boolean> ] [-IsHidden <Boolean> ] [-IsReadOnly <Boolean> ] [-NoDefaultDriveLetter <Boolean> ] [-ThrottleLimit <Int32> ] [ <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
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 |
<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_Partition
You can pipe a Partition object to the InputObject parameter to specify the partition you want to modify by Partition object.
Outputs
The output type is the type of the objects that the cmdlet emits.
- None
Notes
- 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: 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