答案 0 :(得分:1)
您可以使用将提供并行处理的工作流程 您可以通过https://docs.microsoft.com/en-us/system-center/sma/overview-powershell-workflows?view=sc-sma-1801
了解更多有关工作流程的信息。workflow Unzip-File{
Param (
[Object]$Files,
[string]$Destination,
[switch]$SeprateFolders
)
foreach –parallel ($File in $Files){
if($SeprateFolders){
Write-Output "$($file.Name) : Started"
Expand-Archive -Path $File -DestinationPath "$Destination\$($file.Name)"
Write-Output "$($file.Name) : Completed"
}else{
Write-Output "$($file.Name) : Started"
Expand-Archive -Path $File -DestinationPath $Destination
Write-Output "$($file.Name) : Completed"
}
}
}
try{
$ZipFiles = Get-ChildItem C:\Users\Default\Desktop\ZipTest\Source\*.zip
Unzip-File -Files $ZipFiles -Destination "C:\Users\Default\Desktop\ZipTest\Destination" -SeprateFolders
}catch{
Write-Error $_
}
答案 1 :(得分:0)
我会尝试一下:https://github.com/nightroman/SplitPipeline
$Zipfiles = gci [...]
$ZipFiles | Split-Pipeline -Count 10 {process{ Expand-Archive -Path $_ -DestinationPath [...] }}
您还可以为每个项目开始工作,然后在循环结束时接收它们。 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_jobs?view=powershell-6