Trying to generate random files in Windows with this PowerShell script:
param([string]$path = "C:\temp", [int]$size = "1024", [long]$number= "1000")
Write-Host "Path: $path"
Write-Host "Size of file: $size"
Write-Host "Number of files: $number"
Write-Host "Started at:"
Get-Date -Format HH:mm:ss
md -Force $path |out-null
$script:StartTime = $(Get-Date)
for($i=0; $i -le $number - 1 ; $i++){
[Byte[]]$out=@(); 0..($size-1) | %{$out += Get-Random -Minimum 0 -Maximum 255};
[System.IO.File]::WriteAll("$path\$i.bin",$out)
if (-Not ($i % 100) -and ($i -ne 0 )) {
Write-Host "$i were created"
$elapsedTime = $(Get-Date) - $script:StartTime
$script:StartTime = $(Get-Date)
Write-Host "$elapsedTime"
}
}
When I want to increase filesize from 1KB to 1MB, it take a long time for even one file, but I need thousands of those. Is there way to solve this bottleneck?
Aucun commentaire:
Enregistrer un commentaire