PSCompression is a PowerShell module that provides utilities for creating, managing, and extracting zip and tar archives, as well as compressing and decompressing strings. It overcomes limitations in built-in PowerShell archive cmdlets (e.g., 2 GB zip file limits) and supports multiple compression algorithms, including gzip, bzip2, Zstandard, lzip, Brotli, Deflate, and Zlib. Built for cross-platform use, it’s compatible with Windows, Linux, and macOS.
New in recent updates: Full support for reading and extracting password-protected (encrypted) zip entries, including AES encryption.
- Zip Archive Management: Create, list, extract, retrieve content, modify, and remove entries in zip archives with pipeline support.
Now includes full support for reading and extracting password-protected entries (traditional ZipCrypto and AES encryption). - Tar Archive Management: Compress and extract tar archives with support for
gz,bz2,zst,lz, and uncompressed (none) formats. - Tar Entry Management: List, extract, and retrieve content from individual tar entries.
- String Compression: Compress and decompress strings using Brotli, Deflate, Gzip, and Zlib algorithms.
Compress-ZipArchive— Compresses files and folders into a zip archive, overcoming built-in PowerShell limitations.Expand-ZipEntry— Extracts individual zip entries to a destination directory.Get-ZipEntry— Lists zip archive entries from paths or streams, serving as the entry point for zip cmdlets.Get-ZipEntryContent— Retrieves the content of zip entries as text or bytes.New-ZipEntry— Adds new entries to a zip archive from files or paths.Remove-ZipEntry— Removes entries from one or more zip archives.Rename-ZipEntry— Renames entries in one or more zip archives.Set-ZipEntryContent— Sets or appends content to a zip entry.
Note
Due to a .NET limitation, cmdlets like New-ZipEntry, Compress-ZipArchive with -Update, and Set-ZipEntryContent may fail when handling files or content > 2 GB in existing zip archives. As a workaround, recreate the zip archive or use tools like 7-Zip, which support larger files. See issue #19 for details.
Compress-TarArchive— Compresses files and folders into a tar archive with optional compression (gz, bz2, zst, lz, none).Expand-TarArchive— Extracts a tar archive with support for gz, bz2, zst, lz, and uncompressed formats.Expand-TarEntry— Extracts individual tar entries to a destination directory.Get-TarEntry— Lists tar archive entries from paths or streams.Get-TarEntryContent— Retrieves the content of tar entries as text or bytes.
ConvertFrom-BrotliString— Decompresses a Brotli-compressed string.ConvertFrom-DeflateString— Decompresses a Deflate-compressed string.ConvertFrom-GzipString— Decompresses a Gzip-compressed string.ConvertFrom-ZlibString— Decompresses a Zlib-compressed string.ConvertTo-BrotliString— Compresses a string using Brotli.ConvertTo-DeflateString— Compresses a string using Deflate.ConvertTo-GzipString— Compresses a string using Gzip.ConvertTo-ZlibString— Compresses a string using Zlib.
Note
The Compress-GzipArchive and Expand-GzipArchive cmdlets have been removed, as their single-file gzip functionality is now handled by Compress-TarArchive and Expand-TarArchive. For a workaround to compress or decompress single files using gzip, see Example 2 in ConvertTo-GzipString.
Check out the docs for information about how to use this Module.
The module is available through the PowerShell Gallery:
Install-Module PSCompression -Scope CurrentUsergit clone 'https://github.com/santisq/PSCompression.git'
Set-Location ./PSCompression
./build.ps1This module has no external requirements and is compatible with Windows PowerShell 5.1 and PowerShell 7+.
This module is powered by the following open-source projects:
If you find these projects helpful, consider starring their repositories!
Contributions are more than welcome, if you wish to contribute, fork this repository and submit a pull request with the changes.