Powershell script to generate HTML report on files in given folders with specific extensions and size
11/03/2014 – v1.2
Added ‘Report run time’ at the bottom
Fixed bug when no files are found that match criteria
Turned into function
Bundled with EnhancvedHTML2
Added SizeUnit parameter
Screen output will look like:
The HTML report will look like:
A question was posted a few days ago on the Powershell.org Q&A forum:
I’m trying to get people to clean up old files. Never an easy job. To help them out, I want to generate reports of their department folders. One report would list their Powerpoint files, another PDFs and a third, zip files.
Many of us have been in this situation where data sprawl goes a bit out of control. This script helps produce HTML reports that can be customized to report on:
- Files in several folders,
- With specific file extensions,
- Greater than a specific file size,
- File properties reported on can also be customized
The script can be downloaded from the Microsoft Script Center Repository.
The script uses EnahncedHTML2 module which is written by Don Jones in 9/2013. I first met Don at TechEd 2014 in Houston where he delivered several sessions that I attended and enjoyed. In spite of being one of the leading experts on Microsoft business technologies, he’s a down to earth guy who would take the time to answer a question or help out when needed.
To install EnhancedHTML2 module:
- Download it from the Powershell.org public OneDrive. Look under the Creating HTML Reports folder.
- Check your Powershell Module Path. Run $env:PSModulePath.Split(“;”) for example:
- Create a folder named “EnhancedHTML2” under any of the listed paths like c:\Program Files\WindowsPowerShell\Modules\EnhancedHTML2
- Copy the 2 files EnhancedHTML2.psd1 and EnhancedHTML2.psm1 to this folder (part of the downloaded files from #1 above)
- Finally run Import-Module EnahncedHTML2