I was recently taking a training course and the lab guide said “create some files in c:\stuff”.
Sure, I could use Windows Explorer or Command Prompt or even a PowerShell command to do this. I guess the easiest way would be to use Windows Explorer, select a file, copy it (Ctrl+C), then paste it multiple times (Ctrl+V [repeat until your fingers are tired]).
But hey, I’m a geek and I like to script stuff (yes, for fun). But I’m not stupid so I didn’t create a script from scratch. Stéphane van Gulick, a PowerShell MVP, has a nice script at http://powershelldistrict.com/create-files/
However, I like to tinker and can’t leave good enough alone so I forked it and added some additional functionality.
I give you… Create-RandomFiles.ps1 with the following changes
- Added a Progress indicator
- files are created with different sizes
- TotalSize defaults to MB
- added optional name prefix
- added execution statistics
- replaced fsutil.exe with New-Object byte[]