This morning I saw some chatter about using WMI to get defrag information. Curious about the method I found this page on MSDN outlining the various methods on the Win32_Volume class:
Win32_Volume Methods
And, more specifically, I found this page for the Defrag method itself:
Defrag method of the Win32_Volume Class
When I looked at the arguments I only saw one parameter that took input: Force.
The Force parameter required a Boolean ($true or $false) to indicate whether defragmenting of the volume would occur even if free space is low. The default is false. To use this on a specific volume use this syntax:
Now, the Job cmdlet is not necessary, but, I would rather do this to prevent issue with single-threading (and locking up) my shell.
About lamsim
Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.