Shrink VM Disk Commands

Last Modified: Fri, 18 Sep 2026 19:09:48 +0000 ; Created: Fri, 18 Sep 2026 19:09:48 +0000

Note if the virtual disk is bitlocker encrypted you must remove the bitlocker encryption first and then re-establish it as Used Space Only. If the Hypervisor (i.e. VMware) encrypted mode (vTPM) is enabled you do not have to remove it as VMware shrink commands will still work. In most cases you do not have to defrag (inside guest OS) unless your workloads created heavy fragmentation.
  • Delete all snapshots
  • After wiping disk space make sure to power off
  • Defrag RETRIM is not typically supported or required
dism.exe /online /cleanup-image /startcomponentcleanup
cleanmgr.exe
manage-bde -status

manage-bde -off C:


for /L %i in (1,0,2) do @(cls & manage-bde -status C: & timeout /t 5 >nul)

Note: Do not use manage-bde -wipefreespace as that will cause the virtual disk to expand to its full size instead.

forfiles /P "%TEMP%" /S /D -1 /C "cmd /c if @isdir==FALSE del /f /q @path"

forfiles /P "%TEMP%" /S /D -1 /C "cmd /c if @isdir==TRUE rmdir @path" 2>nul

dir /a /s /b "%TEMP%"

  
forfiles /P "%windir%\TEMP" /S /D -1 /C "cmd /c if @isdir==FALSE del /f /q @path"

forfiles /P "%windir%\TEMP" /S /D -1 /C "cmd /c if @isdir==TRUE rmdir @path" 2>nul
 
dir /a /s /b %windir%\Temp
# Might be treated as malware, you can use the GUI "Create a restore point" to manage existing and delete
vssadmin delete shadows /for=C: /all /quiet
sdelete64.exe -z -nobanner C:
"c:\Program Files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -k YOUR_DISK.vmdk
# If you need BitLocker back on again

manage-bde -on C: -UsedSpaceOnly

manage-bde -protectors -get C: -type RecoveryPassword