How it works...
This recipe primarily concentrates on Get-ChildItem and its parameters. The Recurse switch parameter recursively lists out all paths within the specified path. The Name parameter makes PowerShell list out those sub-paths that match the pattern specified.
The rest in this script is about passing the output object from Get-ChildItem into different other cmdlets for further processing. We use the Where-Object cmdlet and a filter script that compares the date of creation of the file and the current date, and then compares the size of the file. We also use the administrative constant (100KB).
When picking the five largest files, we first sort the files by size in descending order, and select the first five from the list.
Again, ...
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