Powershell: Generate File of a Determinate Size in Windows

Ever need to test your mail system with large file?  Below is a rapid method of generating files of random sizes for these testing purposes.
$lrgfilename="c:\tmp\largefile.txt" # change this variable to affect the file location/name
$file = new-object System.IO.FileStream $filename, Create, ReadWrite
$file.SetLength(30MB) # change the value within the () to affect the file size
$file.Close()

No comments:

Post a Comment