powershell - 使用powershell并行解压缩多个文件
解决方案
您可以使用将提供并行处理的工作流您可以在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 $_
}
推荐阅读
- git - Github 可以推送远程引用的数量限制(在 x 时间跨度内)?
- python-3.x - 为什么我的数组中的值不通过我的全位加法器
- node.js - ../bootstrap/scss/_normalize 未找到
- android - SQLLite 更新根本不更新表(Android Studio with Kotlin)
- php - Opencart 的响应类:redirect 和 setOutput
- docker - 如何在 Dockerfile 中编写多行命令
- mysql - 如何获取旧版本 MySQL 中记录的前 3 个值?
- mysql - SQL SUM TOP 5 每个类别的值,然后 SUM 类别总计每个 ID
- python - 后端 Web 服务可以将 selenium 与无头 Chromium 一起使用吗?
- java - 执行 shell 命令时 channelExec.setCommand() 不工作