Sometimes it’s necessary to generate files of random sizes for testing purposes. Here’s how to do this Powershell.

$file = new-object System.IO.FileStream c:\tmp\file.dat, Create, ReadWrite
$file.SetLength(42MB)
$file.Close()