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.
- Zip Archive Management: Create, list, extract, retrieve content, modify, and remove entries in zip archives with pipeline support.
- 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.
| Cmdlet | Alias | Description |
|---|---|---|
| Compress-ZipArchive | zipcompress |
Compresses files and folders into a zip archive, overcoming built-in PowerShell limitations. |
| Expand-ZipEntry | unzipentry |
Extracts individual zip entries to a destination directory. |
| Get-ZipEntry | zipge |
Lists zip archive entries from paths or streams, serving as the entry point for zip cmdlets. |
| Get-ZipEntryContent | zipgec |
Retrieves the content of zip entries as text or bytes. |
| New-ZipEntry | zipne |
Adds new entries to a zip archive from files or paths. |
| Remove-ZipEntry | ziprm |
Removes entries from one or more zip archives. |
| Rename-ZipEntry | zipren |
Renames entries in one or more zip archives. |
| Set-ZipEntryContent | zipsc |
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.
| Cmdlet | Alias | Description |
|---|---|---|
| Compress-TarArchive | tarcompress |
Compresses files and folders into a tar archive with optional compression (gz, bz2, zst, lz, none). |
| Expand-TarArchive | untar |
Extracts a tar archive with support for gz, bz2, zst, lz, and uncompressed formats. |
| Expand-TarEntry | untarentry |
Extracts individual tar entries to a destination directory. |
| Get-TarEntry | targe |
Lists tar archive entries from paths or streams, serving as the entry point for tar cmdlets. |
| Get-TarEntryContent | targec |
Retrieves the content of tar entries as text or bytes. |
| Cmdlet | Alias | Description |
|---|---|---|
| ConvertFrom-BrotliString | frombrotlistring |
Decompresses a Brotli-compressed string. |
| ConvertFrom-DeflateString | fromdeflatestring |
Decompresses a Deflate-compressed string. |
| ConvertFrom-GzipString | fromgzipstring |
Decompresses a Gzip-compressed string. |
| ConvertFrom-ZlibString | fromzlibstring |
Decompresses a Zlib-compressed string. |
| ConvertTo-BrotliString | tobrotlistring |
Compresses a string using Brotli. |
| ConvertTo-DeflateString | todeflatestring |
Compresses a string using Deflate. |
| ConvertTo-GzipString | togzipstring |
Compresses a string using Gzip. |
| ConvertTo-ZlibString | tozlibstring |
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.