magritton
4/29/2020 - 5:55 PM

Random File Create

Creates random files in a folder. These are text files with a random name and small text in the file.

# Provide Folder name and create
$Folder='C:\CodeFiles\TestFiles\Test5'

New-Item -ItemType Directory -Path $Folder

# Create a series of 10 files
for ($x=0;$x -lt 100; $x++)
{
    # Let’s create a completely random filename
    $filename=”$($Folder)\$((Get-Random 100000).tostring()).txt”
    
    write-host "Creating file: $filename"

    # Now we’ll create the file with some content
    Add-Content -Value ‘Just a simple demo file’ -Path $filename

}