我有一段代码在PowerShell中工作得很好。
不过,我希望看到工作量(压缩过程)。
Write-Host "Started zipping files and folders..." -ForegroundColor Yellow
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zip = [System.IO.Compression.ZipFile]::CreateFromDirectory("$Destination\$folderName\",
"$Destination\$folderName.zip", $compressionLevel, $false)
if ($?) {
Write-Host "Zip process success. Exiting..." -ForegroundColor Yellow
Invoke-Item "$Destination"
sleep -Seconds 2
}
else {
Write-Host "Zip process failed." -ForegroundColor Red
}
我假设我需要做的是:
Write-Progress -Activity "Zipping files and folders..." -Status "Progress:" -PercentComplete ($zip/something?)}
我正在使用PowerShell 5.1版
更新:
我可能会更改并使用Incorporated Cmdlet压缩存档