Skip to main content

Invoke-VolumeOptimization

Description

This command will utilize the Optimize-Volume command to defragment or trim a drive if it is compatible. If the drive is not compatible, the standard defrag method will be used.

Usage

  1. Determine the scope of drives to defragment.
  2. For each drive, log a baseline of an analysis scan (works for compatible and non-compatible drives).
  3. Defragment the drive if it is compatible with Optimize-Volume; if not, call the standard defrag method.
  4. Log the results of the defragmentation.
.\Invoke-VolumeOptimization.ps1

This command will attempt a defragmentation of all drives.

.\Invoke-VolumeOptimization.ps1 -Drives C,E

This command will defragment drives C and E.

Parameters

ParameterAliasRequiredDefaultTypeDescription
DrivesFalseall drivesString[]The drives you wish to scan. If left blank, defaults to all drives.

Output

The location of output for log, result, and error files:

.\Invoke-VolumeOptimization-log.txt

Notes

This script may take more than 30 minutes to complete.