How it works...
The execution is similar to the While construct, however, as shown by Iteration 0, the Do–While construct executes the script block once without checking the condition. In our case, we queried the empty directories within the loop. If we had placed this query outside of the loop, we would have had to place it within as well, for loop control. This is inefficient programming.
PowerShell found nine empty directories during the execution of the script block. When the condition check happened after the execution, 9 was evaluated to be greater than 0. The loop ran again. This time, the value of $EmptyDirectories.Count was evaluated to be 4. The loop ran again, and this time again, the value was 4, which is greater than 0; the condition ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access