| external help file | PSCompression.dll-Help.xml |
|---|---|
| Module Name | PSCompression |
| online version | https://github.com/santisq/PSCompression |
| schema | 2.0.0 |
Lists entries from tar archives, supporting file paths and input streams.
Get-TarEntry
[-Path] <String[]>
[-Algorithm <Algorithm>]
[-Type <EntryType>]
[-Include <String[]>]
[-Exclude <String[]>]
[<CommonParameters>]Get-TarEntry
[-InputStream] <Stream>
[-Algorithm <Algorithm>]
[-Type <EntryType>]
[-Include <String[]>]
[-Exclude <String[]>]
[<CommonParameters>]Get-TarEntry
-LiteralPath <String[]>
[-Algorithm <Algorithm>]
[-Type <EntryType>]
[-Include <String[]>]
[-Exclude <String[]>]
[<CommonParameters>]The Get-TarEntry cmdlet lists entries in tar archives, supporting both uncompressed (.tar) and compressed formats (e.g., .tar.gz, .tar.bz2, .tar.zst, .tar.lz). It accepts input from file paths and streams, and outputs TarEntryFile or TarEntryDirectory objects that can be piped to cmdlets like Expand-TarEntry and Get-TarEntryContent. The cmdlet uses SharpZipLib for tar handling, System.IO.Compression for gzip, SharpCompress for lzip, and ZstdSharp for Zstandard.
PS ..\pwsh> Get-TarEntry .\archive.tar
Directory: /folder1/
Type LastWriteTime Size Name
---- ------------- ---- ----
Directory 6/23/2025 11:08 PM folder1
Archive 6/23/2025 11:08 PM 1.00 KB file1.txt
Archive 6/23/2025 11:08 PM 2.00 KB file2.txtThis example lists all entries in an uncompressed tar archive (archive.tar).
PS ..\pwsh> Get-TarEntry *.tar.gz
Directory: /folder1/
Type LastWriteTime Size Name
---- ------------- ---- ----
Directory 6/23/2025 11:08 PM folder1
Archive 6/23/2025 11:08 PM 1.00 KB file1.txt
Archive 6/23/2025 11:08 PM 2.00 KB file2.txtThis example lists entries from all gzip-compressed tar archives in the current directory using wildcard matching.
PS C:\> Get-TarEntry .\archive.tar -Type Archive
Directory: /folder1/
Type LastWriteTime Size Name
---- ------------- ---- ----
Archive 6/23/2025 11:08 PM 1.00 KB file1.txt
Archive 6/23/2025 11:08 PM 2.00 KB file2.txtThis example lists only file entries (excluding directories) from archive.tar using -Type Archive.
PS C:\> Get-TarEntry .\archive.tbz2 -Include folder1/* -Exclude *.txt
Directory: /folder1/
Type LastWriteTime Size Name
---- ------------- ---- ----
Directory 2025-06-23 7:00 PM folder1
Archive 2025-06-23 7:00 PM 3.00 KB image.pngThis example lists entries under folder1/ while excluding any .txt files.
Note
If not specified, the cmdlet infers the compression algorithm from the file extension: gz for .gz, .gzip, .tgz; bz2 for .bz2, .bzip2, .tbz2, .tbz; zst for .zst; lz for .lz; none for .tar. If the extension is unrecognized, it defaults to none (uncompressed tar).
PS C:\> $stream = Invoke-WebRequest https://example.com/archive.tar.gz
PS C:\> $stream | Get-TarEntry -Algorithm gz | Select-Object -First 3
Directory: /docs/
Type LastWriteTime Size Name
---- ------------- ---- ----
Directory 2025-06-23 7:00 PM docs/
Archive 2025-06-23 7:00 PM 1.50 KB readme.md
Archive 2025-06-23 7:00 PM 2.50 KB license.txtThis example lists the first three entries from a gzip-compressed tar archive retrieved via a web request.
Note
When processing a stream, the cmdlet defaults to the gz (gzip) algorithm. Specify -Algorithm (e.g., -Algorithm bz2 for bzip2) if the stream uses a different compression format.
Specifies the compression algorithm used for the tar archive. Accepted values and their corresponding file extensions are:
gz: Gzip compression (.gz,.gzip,.tgz).bz2: Bzip2 compression (.bz2,.bzip2,.tbz2,.tbz)zst: Zstandard compression (.zst).lz: Lzip compression (.lz).none: Uncompressed tar archive (.tar).
Note
If not specified, the cmdlet infers the algorithm from the file extension. If the extension is unrecognized, it defaults to none (uncompressed tar).
Type: Algorithm
Parameter Sets: (All)
Aliases:
Accepted values: gz, bz2, zst, lz, none
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of string patterns to match as the cmdlet lists entries. Matching entries are excluded from the output. Wildcard characters are supported.
Note
Inclusion and exclusion patterns are applied to the entries’ relative paths. Exclusions are applied after inclusions.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueSpecifies an array of string patterns to match as the cmdlet lists entries. Matching entries are included in the output. Wildcard characters are supported.
Note
Inclusion and exclusion patterns are applied to the entries’ relative paths. Exclusions are applied after inclusions.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueSpecifies an input stream containing a tar archive.
Note
- Output from
Invoke-WebRequestis automatically bound to this parameter. - The cmdlet defaults to the
gz(gzip) algorithm for streams. Specify-Algorithmto match the compression type (e.g.,-Algorithm zstfor Zstandard) to avoid errors.
Type: Stream
Parameter Sets: Stream
Aliases: RawContentStream
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: FalseSpecifies one or more paths to tar archives. The value is used exactly as typed, with no wildcard character interpretation.
Type: String[]
Parameter Sets: LiteralPath
Aliases: PSPath
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies one or more paths to tar archives. Wildcard characters are supported.
Type: String[]
Parameter Sets: Path
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: TrueFilters output to include only files (Archive) or only directories (Directory).
Type: EntryType
Parameter Sets: (All)
Aliases:
Accepted values: Directory, Archive
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters. For more information, see about_CommonParameters.
You can pipe a stream containing a tar archive to this cmdlet, such as output from Invoke-WebRequest.
You can pipe strings containing paths to tar archives, such as output from Get-ChildItem or Get-Item.
Outputs objects representing directories or files in the tar archive.