Optimize-Volume
Optimize-Volume [-DriveLetter*] <Char[]> [-Analyze] [-CimSession <CimSession[]>] [-Defrag] [-NormalPriority][-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32>] [-TierOptimize] [-Confirm] [-WhatIf] [<CommonParameters>]
Optimize-Volume [-Analyze] [-CimSession <CimSession[]>] [-Defrag] [-NormalPriority] [-ReTrim] [-SlabConsolidate][-ThrottleLimit <Int32>] [-TierOptimize] -Path* <String[]> [-Confirm] [-WhatIf] [<CommonParameters>]
Optimize-Volume [-Analyze] [-CimSession <CimSession[]>] [-Defrag] [-NormalPriority] [-ReTrim] [-SlabConsolidate][-ThrottleLimit <Int32>] [-TierOptimize] -ObjectId* <String[]> [-Confirm] [-WhatIf] [<CommonParameters>]
Optimize-Volume [-Analyze] [-CimSession <CimSession[]>] [-Defrag] [-NormalPriority] [-ReTrim] [-SlabConsolidate][-ThrottleLimit <Int32>] [-TierOptimize] [-Confirm] [-WhatIf] [<CommonParameters>]
Optimize-Volume [-Analyze] [-CimSession <CimSession[]>] [-Defrag] [-NormalPriority] [-ReTrim] [-SlabConsolidate][-ThrottleLimit <Int32>] [-TierOptimize] -FileSystemLabel* <String[]> [-Confirm] [-WhatIf] [<CommonParameters>]
The Optimize-Volume cmdlet optimizes a volume, performing defragmentation, trim, slab consolidation, and storage tier processing. If no parameter is specified, then the default operation will be performed per the drive type as follows.
-- HDD, Fixed VHD, Storage Space. -Analyze -Defrag.-- Tiered Storage Space. -TierOptimize.-- SSD with TRIM support. -Retrim.-- Storage Space (Thinly provisioned), SAN Virtual Disk (Thinly provisioned), Dynamic VHD, Differencing VHD. -Analyze -SlabConsolidate -Retrim.-- SSD without TRIM support, Removable FAT, Unknown. No operation.
Parameters
-Analyze [<SwitchParameter>]
Analyzes the volume specified for fragmentation statistics. Performs analysis only and reports the current optimization state of the volume.
-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.
-Defrag [<SwitchParameter>]
Indicates that the cmdlet initiates defragmentation on the specified volume. Defragmentation consolidates fragmented regions of files to improve performance of sequential reads or writes.
-DriveLetter <Char[]>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the drive letter of the volume to optimize.
-FileSystemLabel <String[]>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the file system label of the volume to optimize.
-NormalPriority [<SwitchParameter>]
Indicates that this cmdlet the operation at normal priority. By default, the priority is low.
-ObjectId <String[]>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the ID of the volume to optimize.
-Path <String[]>
- This value is required
- Accepts pipeline input ByPropertyName
Specifies the path of the volume to optimize.
-ReTrim [<SwitchParameter>]
Generates TRIM and Unmap hints for all currently unused sectors of the volume, notifying the underlying storage that the sectors are no longer needed and can be purged. This can recover unused capacity on thinly provisioned drives.
-SlabConsolidate [<SwitchParameter>]
Indicates that the cmdlet performs slab consolidation on the storage to optimize slab allocations and to reduce the number of used slabs.
-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.
-TierOptimize [<SwitchParameter>]
Indicates that the cmdlet performs tier optimization of the volume, which places file data on the optimal storage tier according to heat or desired placement. This parameter only applies to tiered spaces volumes with more than one storage tier.
-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_VolumeOutputs
This cmdlet does not generate output.Examples
-
Perform TRIM optimization:
PS C:\> Optimize-Volume -DriveLetter H -ReTrim -Verbose
This example optimizes drive H by re-sending Trim requests. This is useful on SSD media, and thinly provisioned storage.
-
Analyze a volume:
PS C:\> Optimize-Volume -DriveLetter H -Analyze -Verbose
This example reports only the current optimization state of drive H.
-
Defragment a volume:
PS C:\> Optimize-Volume -DriveLetter H -Defrag -Verbose
This example defragments drive H.
-
Perform slab consolidation:
PS C:\> Optimize-Volume -DriveLetter H -SlabConsolidate -Verbose
This example performs slab consolidation on the storage space backing volume H.
-
Tier optimize a volume:
PS C:\> Optimize-Volume -DriveLetter H -TierOptimize
This example performs tier optimization on the tiered storage space backing volume H.
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