The [math]:: accelerator allows us to use the methods of the System.Math class. The Round() method accepts one or two arguments; in case of a single argument, the rounding happens to the nearest integer. The optional second parameter specifies the number of digits after the decimal point.
The Pow() method is almost self-explanatory: 10242 in our case. The Floor() method brought down numbers from 30.00 to less than 31, down to 30.
This is what we did:
- Listed out the files to delete: we subtracted the LastWriteTime from today, and performed a Floor operation on it since we were not allowed to use the -and operator.
- Displayed the files.
- We performed a remove operation on each of the files, while also adding the size of each of the files to $TotalFileSize.
- In the end, we divided $TotalFileSize by 10242 and rounded it off to the nearest MB.