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
 

Optimize-Volume

Optimize-Volume

volume.cdxml

Synopsis

Optimizes a volume.

Syntax

Optimize-Volume [-DriveLetter] [-Analyze] [-AsJob] [-CimSession] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit] [-TierOptimize] [-Confirm] [-WhatIf] [<CommonParameters>]

Optimize-Volume [-Analyze] [-AsJob] [-CimSession] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit] [-TierOptimize] [-Path] [-Confirm] [-WhatIf] [<CommonParameters>]

Optimize-Volume [-Analyze] [-AsJob] [-CimSession] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit] [-TierOptimize] [-ObjectId] [-Confirm] [-WhatIf] [<CommonParameters>]

Optimize-Volume [-Analyze] [-AsJob] [-CimSession] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit] [-TierOptimize] [-InputObject] [-Confirm] [-WhatIf] [<CommonParameters>]

Optimize-Volume [-Analyze] [-AsJob] [-CimSession] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit] [-TierOptimize] [-FileSystemLabel] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The Optimize-Volume cmdlet optimizes a volume, performing such tasks on supported volumes and system SKUs as 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.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-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

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

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-DriveLetter <Char[]>

Specifies the drive letter of the volume to optimize.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-FileSystemLabel <String[]>

Specifies the file system label of the volume to optimize.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-InputObject <CimInstance[]>

Accepts a volume object from the pipeline as input.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByValue)

Accept wildcard characters?

false

-ObjectId <String[]>

Specifies the ID of the volume to optimize.

Aliases

Id

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

-Path <String[]>

Specifies the path of the volume to optimize.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

True (ByPropertyName)

Accept wildcard characters?

false

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

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-SlabConsolidate <SwitchParameter>

Indicates that the cmdlet performs slab consolidation on the storage to optimize slab allocations and to reduce the number of used slabs.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

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

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

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

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

Return Type


Notes

None

Examples

Example 1: Perform TRIM optimization

This example optimizes drive H by re-sending Trim requests. This is useful on SSD media, and thinly provisioned storage.

PS C:\>Optimize-Volume -DriveLetter H -ReTrim –Verbose

Example 2: Analyze a volume

This example reports only the current optimization state of drive H.

PS C:\>Optimize-Volume -DriveLetter H -Analyze –Verbose

Example 3: Defragment a volume

This example defragments drive H.

PS C:\>Optimize-Volume -DriveLetter H -Defrag –Verbose

Example 4: Perform slab consolidation

This example performs slab consolidation on the storage space backing volume H.

PS C:\>Optimize-Volume -DriveLetter H -SlabConsolidate –Verbose

Example 5: Tier optimize a volume

This example performs tier optimization on the tiered storage space backing volume H.

PS C:\>Optimize-Volume -DriveLetter H -TierOptimize

Online Version
Format-Volume
Get-Volume
Repair-Volume
Set-Volume