The performance of both the Windows and Powershell Zip utilities is abysmal
The following Powershell script enables a Zip operation on approximately 0.33GB of data consisting of around 59,000 files to go from minutes down to less than a minute using 7-Zip instead of Powershells Compress-Archive
Ref: https://stackoverflow.com/a/25288780
Features
- Raise an error if 7zip is missing
- Create a timestamped filename
- Use environment variables to locate common directories for portability
- Skip a folder that should not be included in the resulting zip file using the
-xr!
syntax - Display a nice progress GUI with
7zg.exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use 7zg.exe for GUI or just 7z.exe for none | |
$7zipPath = "$env:ProgramFiles\7-Zip\7zg.exe" | |
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) { | |
throw "7 zip file '$7zipPath' not found. Contact Toggen" | |
} | |
Set-Alias Start-SevenZip $7zipPath | |
$Source = "$env:ProgramData\Software Assistant\Assistant\Data" | |
$DateTime = (Get-Date -Format "yyyyMMddHHmmss") | |
# adjust to copy zip to onedrive for backup | |
$Target = "C:\Users\YourUser\OneDrive - Your Company Pty Ltd\0. Tax Assistant Backups" | |
# location of output zip when testing | |
$Target = "c:\temp\" | |
$TargetZip = Join-Path $Target "SoftwareAssistantBackup-$DateTime.zip" | |
Start-SevenZip a -xr!_Updates $TargetZip $Source |
7-Zip GUI pops up so you can view the progress

0 Comments