I encountered a scenario that requires conducting performance testing on data-containing files, and this script precisely facilitates the process. You can specify the desired size, number of files, and the designated path, and the script will efficiently create the specified files for you
The below variable is for the path where the files will be created
$folderPath = “C:\temp\upload1”
$folderPath = "C:\temp\upload1" $fileSizeMB = 10 $fileCount = 100 # Create the output folder if it doesn't exist if (!(Test-Path -Path $folderPath)) { New-Item -ItemType Directory -Path $folderPath | Out-Null } # Generate the files $progress = 0 for ($i = 1; $i -le $fileCount; $i++) { $fileName = "File$i.txt" $filePath = Join-Path -Path $folderPath -ChildPath $fileName $fileContent = New-Object byte[] (1024 * 1024 * $fileSizeMB) $stream = [System.IO.File]::Create($filePath) $stream.Write($fileContent, 0, $fileContent.Length) $stream.Close() $progress += 1 Write-Progress -Activity "Creating Files" -Status "Progress: $progress/$fileCount" -PercentComplete (($progress / $fileCount) * 100) } Write-Output "Files created successfully in: $folderPath"
Thanks for reading