baksatibi

Untitled

Sep 19th, 2015
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param(
  2.     [Parameter(Mandatory=$true)]
  3.     [string]$name,
  4.     [Parameter(Mandatory=$true)]
  5.     [long]$size
  6. )
  7.  
  8. $random = new-object Random
  9. $linePerMB = 1024
  10. $dataPerLine = 256
  11. $lines = @("") * $linePerMB
  12. $data = @(0) * $dataPerLine
  13.  
  14. for($mb = 1; $mb -le $size / 1MB; $mb++) {
  15.     for($line = 0; $line -lt $linePerMB; $line++) {
  16.         for($i = 0; $i -lt $dataPerLine; $i++) {
  17.             $data[$i] = $random.Next(100, 1000)
  18.         }
  19.        
  20.         $lines[$line] = [string]::Join(',', $data)
  21.     }
  22.    
  23.     [string]::Join("`n", $lines) | out-file $name -encoding utf8 -append
  24.     write-host "${mb}MB done"
  25. }
Advertisement
Add Comment
Please, Sign In to add comment