hello, I am trying to parallelize my script so that it can run on 8 or more threads, I have a folder that contains 6 million or so files, the script I am using now is extremely slow and only runs on one core. I can implement this in c# easier and faster, but my manager wants to use PowerShell. I have tried to adapt my script with run jobs and -parallel...etc.; but I keep getting errors. as you can tell I am not a scripting guy (I am a programming guy), any help would be appreciated thanks.
$FilePath = Resolve-Path * -Relative
Get-ChildItem $FilePath | %{
$ScriptBlock = {
Foreach {$i = $j = 0} {
if ($i++ % 13000 -eq 0) {
$dest = "files $j"
md $dest
$j++
}
Move-Item $_ $dest
}
}
Start-Job $ScriptBlock
}
Get-Job
While (Get-Job -State "Running")
{
Start-Sleep 10
}
Get-Job | Receive-Job