PowerShell – Creating Dummy files

Here’s a function I wrote to create a large dummy file either filled with zero’s or random characters. The -Target parameter must be eitehr a file including the path or just the path. If the path does not exist, it will be created. If only a path is provided a file with a random file name is generated.

Run the following command to create a dummy file of 10 MB with random content

Run the following command to create a dummy file dummy10mb.txt with random content

Run the following command to create a dummy file of 20 MB filled with zeros

If you prefer to see what is going on, add the -Showprogress option. And last but not least the function also supports the -whatif option.

3 Replies to “PowerShell – Creating Dummy files”

  1. This is a good script.
    However, is it possible to get it working with a UNC path ?
    like in windows network “\\server\share”, or “\\192.168.1.1\share”
    i also can’t mount the share as a networkdrive “z:\” and use that.
    i get the same error at about line 39, telling me my path is empty.

  2. < and > substitution at the beginning and end of the documentation section at the top break the script.

Leave a Reply