How to defrag drives with PowerShell in Windows Server 2012?

optimizeBesides repairing disks, defragmenting them is another common server maintenance task. Here is the guide lines for defragmenting drives using PowerShell.

  1. Open PowerShell window
  2. You may want to examine whether disks are fragmented or not, so execute Optimize-Volume D –Analyze –Verbose, where D is your drive letter
  3. You will see the result at the end of report. If necessary to defrag, then run Optimize-Volume D –Verbose 
  4. Wanting to run this command on a remote computer, put –CimSession “Remote Computer Name”, without quotation marks, after the command
  5. At the end, for more information and help, run Get-Help Optimize-Volume, as I did in the above picture
%d bloggers like this: