Export (0) Print
Expand All
Expand Minimize

Optimize-Volume

Windows Server 2012 R2 and Windows 8.1

Updated: June 4, 2014

Applies To: Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2

Optimize-Volume

Optimizes a volume.

Syntax

Parameter Set: ByDriveLetter
Optimize-Volume [-DriveLetter] <Char[]> [-Analyze] [-AsJob] [-CimSession <CimSession[]> ] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32> ] [-TierOptimize] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ById
Optimize-Volume -ObjectId <String[]> [-Analyze] [-AsJob] [-CimSession <CimSession[]> ] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32> ] [-TierOptimize] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ByLabel
Optimize-Volume -FileSystemLabel <String[]> [-Analyze] [-AsJob] [-CimSession <CimSession[]> ] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32> ] [-TierOptimize] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ByPaths
Optimize-Volume -Path <String[]> [-Analyze] [-AsJob] [-CimSession <CimSession[]> ] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32> ] [-TierOptimize] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: InputObject (cdxml)
Optimize-Volume -InputObject <CimInstance[]> [-Analyze] [-AsJob] [-CimSession <CimSession[]> ] [-Defrag] [-ReTrim] [-SlabConsolidate] [-ThrottleLimit <Int32> ] [-TierOptimize] [-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

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

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

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

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

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

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

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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


Required?

false

Position?

named

Default Value

false

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.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • This cmdlet does not generate output.


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

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft