Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# CHANGELOG

## 12/13/2025

- **Native Zip Entry Objects**

Zip entries returned by `Get-ZipEntry` (and created by `New-ZipEntry`) are now backed directly by `ICSharpCode.SharpZipLib.Zip.ZipEntry`.
This exposes additional useful properties on `ZipEntryBase` derived objects:
- `IsEncrypted` (`bool`) – Indicates whether the entry is encrypted.
- `AESKeySize` (`int`) – AES key size (0, 128, 192, or 256) if AES encryption is used.
- `CompressionMethod` (`ICSharpCode.SharpZipLib.Zip.CompressionMethod`) – The actual compression method used.
- `Comment` (`string`) – The entry comment.
- `Crc` (`long`) – Cyclic redundancy check.

- **Support for Encrypted Zip Entries**

`Get-ZipEntryContent` and `Expand-ZipEntry` now fully support reading and extracting password-protected entries.
A new common parameter has been added to both cmdlets:

```powershell
-Password <SecureString>
```

- If an entry is encrypted and no password is provided, the cmdlets will securely prompt for one.
- Examples and detailed guidance for handling encrypted entries have been added to the help documentation.

- **Documentation Improvements**

All cmdlet help files have been reviewed and updated for consistency and clarity.
Significant enhancements to `Get-ZipEntryContent` and `Expand-ZipEntry` help:
- Added dedicated examples demonstrating password-protected entry handling.
- Updated parameter descriptions and notes for the new `-Password` parameter.
- Improved phrasing, removed outdated example output, and ensured uniform formatting across the module.

## 07/02/2025

- Added `AssemblyLoadContext` support for PowerShell 7 (.NET 8.0 or later) to resolve DLL hell by isolating module dependencies. PowerShell 5.1 (.NET Framework) users can't get around this issue due to lack of `AssemblyLoadContext` in that runtime.
Expand Down
161 changes: 28 additions & 133 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,143 +22,38 @@

## Cmdlets

### Zip Archive Cmdlets

<table>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/Compress-ZipArchive.md">Compress-ZipArchive</a></td>
<td><code>zipcompress</code></td>
<td>Compresses files and folders into a zip archive, overcoming built-in PowerShell limitations.</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-ZipEntry.md">Expand-ZipEntry</a></td>
<td><code>unzipentry</code></td>
<td>Extracts individual zip entries to a destination directory.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-ZipEntry.md">Get-ZipEntry</a></td>
<td><code>zipge</code></td>
<td>Lists zip archive entries from paths or streams, serving as the entry point for zip cmdlets.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-ZipEntryContent.md">Get-ZipEntryContent</a></td>
<td><code>zipgec</code></td>
<td>Retrieves the content of zip entries as text or bytes.</td>
</tr>
<tr>
<td><a href="docs/en-US/New-ZipEntry.md">New-ZipEntry</a></td>
<td><code>zipne</code></td>
<td>Adds new entries to a zip archive from files or paths.</td>
</tr>
<tr>
<td><a href="docs/en-US/Remove-ZipEntry.md">Remove-ZipEntry</a></td>
<td><code>ziprm</code></td>
<td>Removes entries from one or more zip archives.</td>
</tr>
<tr>
<td><a href="docs/en-US/Rename-ZipEntry.md">Rename-ZipEntry</a></td>
<td><code>zipren</code></td>
<td>Renames entries in one or more zip archives.</td>
</tr>
<tr>
<td><a href="docs/en-US/Set-ZipEntryContent.md">Set-ZipEntryContent</a></td>
<td><code>zipsc</code></td>
<td>Sets or appends content to a zip entry.</td>
</tr>
</table>
### Zip Archive

- [__`Compress-ZipArchive`__](docs/en-US/Compress-ZipArchive.md) — Compresses files and folders into a zip archive, overcoming built-in PowerShell limitations.
- [__`Expand-ZipEntry`__](docs/en-US/Expand-ZipEntry.md) — Extracts individual zip entries to a destination directory.
- [__`Get-ZipEntry`__](docs/en-US/Get-ZipEntry.md) — Lists zip archive entries from paths or streams, serving as the entry point for zip cmdlets.
- [__`Get-ZipEntryContent`__](docs/en-US/Get-ZipEntryContent.md) — Retrieves the content of zip entries as text or bytes.
- [__`New-ZipEntry`__](docs/en-US/New-ZipEntry.md) — Adds new entries to a zip archive from files or paths.
- [__`Remove-ZipEntry`__](docs/en-US/Remove-ZipEntry.md) — Removes entries from one or more zip archives.
- [__`Rename-ZipEntry`__](docs/en-US/Rename-ZipEntry.md) — Renames entries in one or more zip archives.
- [__`Set-ZipEntryContent`__](docs/en-US/Set-ZipEntryContent.md) — 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](https://github.com/santisq/PSCompression/issues/19) for details.

### Tar Archive Cmdlets

<table>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/Compress-TarArchive.md">Compress-TarArchive</a></td>
<td><code>tarcompress</code></td>
<td>Compresses files and folders into a tar archive with optional compression (gz, bz2, zst, lz, none).</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-TarArchive.md">Expand-TarArchive</a></td>
<td><code>untar</code></td>
<td>Extracts a tar archive with support for gz, bz2, zst, lz, and uncompressed formats.</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-TarEntry.md">Expand-TarEntry</a></td>
<td><code>untarentry</code></td>
<td>Extracts individual tar entries to a destination directory.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-TarEntry.md">Get-TarEntry</a></td>
<td><code>targe</code></td>
<td>Lists tar archive entries from paths or streams, serving as the entry point for tar cmdlets.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-TarEntryContent.md">Get-TarEntryContent</a></td>
<td><code>targec</code></td>
<td>Retrieves the content of tar entries as text or bytes.</td>
</tr>
</table>

### String Compression Cmdlets

<table>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/ConvertFrom-BrotliString.md">ConvertFrom-BrotliString</a></td>
<td><code>frombrotlistring</code></td>
<td>Decompresses a Brotli-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-DeflateString.md">ConvertFrom-DeflateString</a></td>
<td><code>fromdeflatestring</code></td>
<td>Decompresses a Deflate-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-GzipString">ConvertFrom-GzipString</a></td>
<td><code>fromgzipstring</code></td>
<td>Decompresses a Gzip-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-ZlibString.md">ConvertFrom-ZlibString</a></td>
<td><code>fromzlibstring</code></td>
<td>Decompresses a Zlib-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-BrotliString.md">ConvertTo-BrotliString</a></td>
<td><code>tobrotlistring</code></td>
<td>Compresses a string using Brotli.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-DeflateString.md">ConvertTo-DeflateString</a></td>
<td><code>todeflatestring</code></td>
<td>Compresses a string using Deflate.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-GzipString.md">ConvertTo-GzipString</a></td>
<td><code>togzipstring</code></td>
<td>Compresses a string using Gzip.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-ZlibString.md">ConvertTo-ZlibString</a></td>
<td><code>tozlibstring</code></td>
<td>Compresses a string using Zlib.</td>
</tr>
</table>
### Tar Archive

- [__`Compress-TarArchive`__](docs/en-US/Compress-TarArchive.md) — Compresses files and folders into a tar archive with optional compression (gz, bz2, zst, lz, none).
- [__`Expand-TarArchive`__](docs/en-US/Expand-TarArchive.md) — Extracts a tar archive with support for gz, bz2, zst, lz, and uncompressed formats.
- [__`Expand-TarEntry`__](docs/en-US/Expand-TarEntry.md) — Extracts individual tar entries to a destination directory.
- [__`Get-TarEntry`__](docs/en-US/Get-TarEntry.md) — Lists tar archive entries from paths or streams.
- [__`Get-TarEntryContent`__](docs/en-US/Get-TarEntryContent.md) — Retrieves the content of tar entries as text or bytes.

### String Compression

- [__`ConvertFrom-BrotliString`__](docs/en-US/ConvertFrom-BrotliString.md) — Decompresses a Brotli-compressed string.
- [__`ConvertFrom-DeflateString`__](docs/en-US/ConvertFrom-DeflateString.md) — Decompresses a Deflate-compressed string.
- [__`ConvertFrom-GzipString`__](docs/en-US/ConvertFrom-GzipString.md) — Decompresses a Gzip-compressed string.
- [__`ConvertFrom-ZlibString`__](docs/en-US/ConvertFrom-ZlibString.md) — Decompresses a Zlib-compressed string.
- [__`ConvertTo-BrotliString`__](docs/en-US/ConvertTo-BrotliString.md) — Compresses a string using Brotli.
- [__`ConvertTo-DeflateString`__](docs/en-US/ConvertTo-DeflateString.md) — Compresses a string using Deflate.
- [__`ConvertTo-GzipString`__](docs/en-US/ConvertTo-GzipString.md) — Compresses a string using Gzip.
- [__`ConvertTo-ZlibString`__](docs/en-US/ConvertTo-ZlibString.md) — 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`](./docs/en-US/ConvertTo-GzipString.md#example-2-create-a-gzip-compressed-file-from-a-string).
Expand Down
Binary file added assets/helloworld.zip
Binary file not shown.
31 changes: 13 additions & 18 deletions docs/en-US/Compress-TarArchive.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ schema: 2.0.0

## SYNOPSIS

The `Compress-TarArchive` cmdlet creates a compressed tar archive file from one or more specified files or directories. It supports multiple compression algorithms and provides flexible file inclusion and exclusion options, similar to the `Compress-ZipArchive` cmdlet.
The `Compress-TarArchive` cmdlet creates a compressed tar archive file from one or more specified files or directories. It supports multiple compression algorithms and provides flexible file inclusion and exclusion options, similar to the `Compress-ZipArchive` cmdlet in this module.

## SYNTAX

Expand Down Expand Up @@ -43,7 +43,7 @@ Compress-TarArchive

## DESCRIPTION

The `Compress-TarArchive` cmdlet creates a tar archive, optionally compressed with algorithms like gzip, bzip2, zstd, or lz4, in a PowerShell-native environment. It simplifies file and directory archiving by integrating seamlessly with PowerShell’s object-oriented pipeline, allowing flexible file selection through cmdlets like `Get-ChildItem` or `Get-Item`. With support for selective inclusion via `-Exclude`, customizable compression levels, and the ability to overwrite existing archives, it provides a convenient alternative to traditional tar utilities for PowerShell users, while preserving directory structures and metadata.
The `Compress-TarArchive` cmdlet creates a tar archive, optionally compressed with algorithms like gzip, bzip2, zstd, or lz4, in a PowerShell-native environment. It simplifies file and directory archiving by integrating seamlessly with PowerShell’s object-oriented pipeline, allowing flexible file selection through cmdlets like `Get-ChildItem` or `Get-Item`. With support for selective exclusion via `-Exclude`, customizable compression levels, and the ability to overwrite existing archives, it provides a convenient alternative to traditional tar utilities for PowerShell users, while preserving directory structures and metadata.

## EXAMPLES

Expand All @@ -57,37 +57,35 @@ Get-ChildItem C:\Logs -Recurse -Filter *.log |
This example demonstrates how to compress all `.log` files in the `C:\Logs` directory into a gzip-compressed tar archive named `logs.tar.gz` in the `C:\Archives` directory.

> [!NOTE]
> If not specified, the cmdlet will use the gzip algorithm as default.
> If not specified, the cmdlet uses the gzip algorithm as default.

### Example 2: Compress a folder using `Fastest` Compression Level

```powershell
Compress-TarArchive -Path .\path -Destination myPath.tar.gz -CompressionLevel Fastest
Compress-TarArchive -Path . -Destination myPath.tar.gz -CompressionLevel Fastest
```

This example shows how to compress the entire path directory into a gzip-compressed tar archive named `myPath.tar.gz` using the `Fastest` compression level for quicker processing.
This example shows how to compress the current directory (`.`) into a gzip-compressed tar archive named `myPath.tar.gz` using the `Fastest` compression level for quicker processing.

### Example 3: Replacing an existing Tar Archive
### Example 3: Overwrite an existing tar archive

```powershell
Compress-TarArchive -Path .\path -Destination dest.tar.gz -Force
Compress-TarArchive -Path .\Path -Destination dest.tar.gz -Force
```

This example illustrates how to create a new tar archive named `dest.tar.gz` from the path directory, overwriting any existing archive with the same name using the `-Force` parameter.

### Example 4: Exclude files and folders from source

```powershell
Compress-TarArchive -Path .\path -Destination myPath.tar.gz -Exclude *.xyz, *\test\*
Compress-TarArchive -Path .\Path -Destination myPath.tar.gz -Exclude *.xyz, *\test\*
```

This example shows how to compress all items in `path` excluding all files having a `.xyz` extension and excluding
a folder with name `test` and all its child items.
This example shows how to compress all items in `path` excluding all files having a `.xyz` extension, any folder named `test` and all its child items.

> [!TIP]
>
> The `-Exclude` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards?view=powershell-7.4&viewFallbackFrom=powershell-7.3),
exclusion patterns are tested against the items `.FullName` property.
> The `-Exclude` parameter supports [wildcard patterns](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards). Exclusion patterns are tested against each item's `.FullName` property.

### Example 5: Compress a directory using bzip2 algorithm

Expand All @@ -113,14 +111,14 @@ Aliases:
Accepted values: gz, bz2, zst, lz, none
Required: False
Position: Named
Default value: none
Default value: gz
Accept pipeline input: False
Accept wildcard characters: False
```

### -CompressionLevel

Specifies the compression level for the selected algorithm, balancing speed and file size. See [`CompressionLevel` Enum](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel) for details. The default is algorithm-dependent but typically `Optimal`.
Specifies the compression level for the selected algorithm, balancing speed and file size. The default is algorithm-dependent but typically `Optimal`.

```yaml
Type: CompressionLevel
Expand Down Expand Up @@ -156,9 +154,6 @@ Accept wildcard characters: False

Specifies an array of string patterns to exclude files or directories from the archive. Matching items are excluded based on their `.FullName` property. Wildcard characters are supported.

> [!NOTE]
> Patterns are tested against the object's `.FullName` property.

```yaml
Type: String[]
Parameter Sets: (All)
Expand Down Expand Up @@ -263,7 +258,7 @@ This cmdlet is designed to provide a PowerShell-native way to create tar archive

## RELATED LINKS

[__Compress-ZipArchive__](https://github.com/santisq/PSCompression)
[__`Compress-ZipArchive`__](https://github.com/santisq/PSCompression)

[__SharpZipLib__](https://github.com/icsharpcode/SharpZipLib)

Expand Down
Loading