Compress-Archive
Zip a folder or files
Compress-Archive -Path .\docs -DestinationPath .\docs.zip
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Compress-Archive
- All versions Cannot add files larger than 2 GB, in 5.1 and 7 alike. Hidden files are skipped, and on Linux and macOS so are files whose names start with a dot.
Zips files or a whole folder. Passing a folder puts the folder itself inside the zip. Passing .\docs\* puts only its contents in.
Common parameters
-DestinationPathis the.zipto create.-Updateadds or replaces files in an existing zip.-Forceoverwrites an existing zip.-CompressionLevel Fastesttrades size for speed.
Try this
Compress-Archive -Path .\docs\*.md -DestinationPath .\markdown.zip -Force
For big files, use tar.exe, which is built into Windows 10 and 11:
tar.exe -a -c -f .\docs.zip .\docs
Want a dated name like docs-20260107-0930.zip? Use the zip builder.
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | zip -r docs.zip docs |
| cmd.exe | tar -a -c -f docs.zip docs |
More in From bash and From cmd.