Last active
January 16, 2019 18:49
-
-
Save justusiv/774ea7ab4c0a43b5b8c3b0765dc77aea to your computer and use it in GitHub Desktop.
Powershell Random Data Creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CreateFiles(){ | |
Param( | |
$bytes = 10MB, | |
$count = 10000, | |
$path = "e:\files", | |
$verbosecount = 10, | |
$verbose = $true, | |
$filename = "" | |
) | |
$silent = mkdir $path -ErrorAction SilentlyContinue | |
$item = 0 | |
$totalBytes = 0 | |
while ($item -lt $count){ | |
$item++ | |
$totalBytes += $bytes | |
[System.Security.Cryptography.RNGCryptoServiceProvider] $rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider | |
$rndbytes = New-Object byte[] $bytes | |
$rng.GetBytes($rndbytes) | |
#[System.IO.File]::WriteAllBytes("$($env:TEMP)\test.txt", $rndbytes) | |
[System.IO.File]::WriteAllBytes("$path\$filename$item.txt", $rndbytes) | |
if (($item % $verbosecount -eq 0) -and ($verbose)) {write-host "Loop:"$item "of"$count;write-host "Totalsize:" ($totalBytes /1024/1024)"MB"} | |
} | |
} | |
### Examples ### | |
#CreateFiles -bytes 10KB -path e:\files -filename small -count 25000 | |
#CreateFiles -bytes 10MB -path e:\files -filename Large -count 25000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment