Optimize-Volume supports different operations depending on the drive type. The command shown uses -Retrim, which is supported for SSD with TRIM support. If the hardware backing the volume does not support that operation, PowerShell returns the error shown.
Use the cmdlet according to the volume type:
- To check the current optimization state only:
Optimize-Volume -DriveLetter C -Analyze -Verbose
- If the volume is an HDD, Fixed VHD, or Storage Space, use defragmentation:
Optimize-Volume -DriveLetter C -Defrag -Verbose
- If the volume is a tiered Storage Space, use tier optimization:
Optimize-Volume -DriveLetter C -TierOptimize
- If the volume is a thinly provisioned Storage Space, SAN virtual disk, Dynamic VHD, or Differencing VHD, the supported operations are analysis, slab consolidation, and retrim.
If no parameter is specified, Optimize-Volume performs the default operation for the detected drive type:
- HDD, Fixed VHD, Storage Space:
-Analyze -Defrag - Tiered Storage Space:
-TierOptimize - SSD with TRIM support:
-Retrim - Thinly provisioned Storage Space, SAN virtual disk, Dynamic VHD, Differencing VHD:
-Analyze -SlabConsolidate -Retrim - SSD without TRIM support, Removable FAT, Unknown: no operation
A practical way to proceed is:
Optimize-Volume -DriveLetter C -Analyze -Verbose
Then run the operation that matches the reported storage type. If drive C: is not backed by hardware that supports TRIM, -Retrim will not run successfully.
If this is a Failover Cluster environment, Storage module cmdlets operate at the cluster level across all servers in the cluster.