Zip Files with Compress-Archive
Create or update a .zip from any files or folder contents straight from PowerShell.
01Command
$ Compress-Archive -Path .\project\* -DestinationPath .\project-backup.zip -Force02What it does
Compress-Archive creates standard ZIP files that Explorer can open natively. `Path folder\*` archives the folder's contents, while `Path folder` archives the folder itself as a subfolder. If the destination exists, use -Update to add changed files or -Force to overwrite the whole archive. Its companion Expand-Archive extracts them back.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Compress-Archive (Microsoft.PowerShell.Archive)Evidence: Documents Compress-Archive with -Path, -DestinationPath, -Force and the update behavior when the destination zip exists.
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
Unzip archives from PowerShell, including into a non-existent destination that gets created.
Search inside text files and logs with regex, returning file, line number and match.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.