To reclaim space in virtual environments and thin provisioned storage facilities, SDelete from SysInternals is probably the most used tool on Windows to clear out unused space of a volume, allowing the SAN to release these data blocks back to the storage pool.
But while SDelete is robust, it has a few (minor) limitations:
The script creates an empty ("zeroed") 1 GB file and copies that file until the free space drops to less than 1 GB, after which the empty files are deleted again. This method is much faster and also works with mount points.
Its usage is simple:
[PS] > .\NimbleFastReclaim.ps1 - Filepath
- LogFile (DEFAULT=C:\temp\NimbleFastReclaim.log) - CycleWait(s) (DEFAULT=0)
Note that you may get a security prompt and/or may have to set the execution policy (Set-ExecutionPolicy RemoteSigned).
[PS] > .\NimbleFastReclaim.ps1 -FilePath K: [PS] > .\NimbleFastReclaim.ps1 -FilePath C:\path\to\mountpoint