Set-Partition
Set-Partition [-DiskNumber*] <UInt32> [-PartitionNumber*] <UInt32> [-CimSession <CimSession[]>] [-GptType<System.String>] [-IsActive <Boolean>] [-IsDAX] [-IsHidden <Boolean>] [-IsReadOnly <Boolean>] [-IsShadowCopy][-MbrType <System.UInt16>] [-NoDefaultDriveLetter <Boolean>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf][<CommonParameters>]
Set-Partition [-DiskNumber*] <UInt32> [-PartitionNumber*] <UInt32> [-CimSession <CimSession[]>] [-IsOffline<Boolean>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-IsOffline <Boolean>] [-ThrottleLimit <Int32>] -DriveLetter* <Char>[-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-GptType <System.String>] [-IsActive <Boolean>] [-IsDAX] [-IsHidden<Boolean>] [-IsReadOnly <Boolean>] [-IsShadowCopy] [-MbrType <System.UInt16>] [-NoDefaultDriveLetter <Boolean>][-ThrottleLimit <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-NewDriveLetter <Char>] [-ThrottleLimit <Int32>] -DriveLetter* <Char>[-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-NewDriveLetter <Char>] [-ThrottleLimit <Int32>] -DiskId* <String>-Offset* <UInt64> [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-NewDriveLetter <Char>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf][<CommonParameters>]
Set-Partition [-DiskNumber*] <UInt32> [-PartitionNumber*] <UInt32> [-CimSession <CimSession[]>] [-NewDriveLetter<Char>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-IsOffline <Boolean>] [-ThrottleLimit <Int32>] -DiskId* <String>-Offset* <UInt64> [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-IsOffline <Boolean>] [-ThrottleLimit <Int32>] [-Confirm] [-WhatIf][<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-GptType <System.String>] [-IsActive <Boolean>] [-IsDAX] [-IsHidden<Boolean>] [-IsReadOnly <Boolean>] [-IsShadowCopy] [-MbrType <System.UInt16>] [-NoDefaultDriveLetter <Boolean>][-ThrottleLimit <Int32>] -DriveLetter* <Char> [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Partition [-CimSession <CimSession[]>] [-GptType <System.String>] [-IsActive <Boolean>] [-IsDAX] [-IsHidden<Boolean>] [-IsReadOnly <Boolean>] [-IsShadowCopy] [-MbrType <System.UInt16>] [-NoDefaultDriveLetter <Boolean>][-ThrottleLimit <Int32>] -DiskId* <String> -Offset* <UInt64> [-Confirm] [-WhatIf] [<CommonParameters>]
The Set-Partition cmdlet sets the attributes of a partition, including active, read-only, hidden, offline, and the drive letter.
Parameters
-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.
-DiskId <String>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the disk ID of the partition to modify.
-DiskNumber <UInt32>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies an array of disk numbers. These represent the disks on which the partitions reside to modify.
-DriveLetter <Char>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the drive letter of the partition to modify.
-GptType [<System.String>]
Sets the type of a GPT partition to a specific GUID.
-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.
-IsDAX [<SwitchParameter>]
Formats a volume as a DirectAccess (DAX) volume.
DAX provides applications with direct access and byte-addressability options via memory mapping on storage class memory (SCM) devices, such as NVDIMM-N.
If you do not specify the IsDAX parameter, the cmdlet defaults to a regular, non-DAX volume.
-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.
-IsOffline [<Boolean>]
Takes the partition offline until explicitly brought back online, or until an access path is added to the partition.
-IsReadOnly [<Boolean>]
Sets the partition to be read-only (IsReadOnly $true) or read-write (IsReadOnly $false).
-IsShadowCopy [<SwitchParameter>]
-MbrType [<System.UInt16>]
Sets the type of an MBR partition to a specific numeric ID.
-NewDriveLetter [<Char>]
Specifies the new drive letter for the partition.
-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.
-Offset <UInt64>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the partition's offset from the beginning of the disk, measured in bytes.
-PartitionNumber <UInt32>
- This value is required
Specifies the number of the partition.
-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 PowerShellr 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.
-Confirm [<SwitchParameter>]
- Default value is false
Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.
-WhatIf [<SwitchParameter>]
- Default value is false
Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run.
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.
Inputs
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_PartitionOutputs
NoneExamples
-
Set the partition to read-only:
PS C:\> Set-Partition -DriveLetter Y -IsReadOnly $True
This example makes partition Y read-only.
-
Set an MBR partition to active:
PS C:\> Set-Partition -DriveLetter Y -IsActive $True
This example makes the MBR partition Y active.
-
Hide the partition:
PS C:\> Set-Partition -DriveLetter Y -IsHidden $True
This example hides partition Y.
-
Take the partition offline:
PS C:\> Set-Partition -DriveLetter Y -IsOffline $True
This example takes the partition and volume offline.
-
Change the drive letter:
PS C:\> Set-Partition -DriveLetter Y -NewDriveLetter Z
This example changes the drive letter from Y to Z.
This work is licensed under a Creative Commons Attribution 4.0 International. It is attributed to Microsoft Corporation and can be found here.
PowerShell Commands