| external help file | PSCompression.dll-Help.xml |
|---|---|
| Module Name | PSCompression |
| online version | https://github.com/santisq/PSCompression |
| schema | 2.0.0 |
Extracts selected RAR archive entries to a destination directory while preserving their relative paths.
Expand-RarEntry
-InputObject <RarEntry[]>
[[-Destination] <String>]
[-Password <SecureString>]
[-Force]
[-PassThru]
[<CommonParameters>]The Expand-RarEntry cmdlet extracts RAR entries produced by Get-RarEntry to a destination directory. Extracted entries preserve their original relative paths and directory structure from the archive. It supports extracting entries from RAR archives on disk as well as from streams, including password-protected entries.
PS /> Get-RarEntry .\archive.rar -Include *.txt | Expand-RarEntryThis example extracts only the .txt files from archive.rar to the current directory, preserving their relative paths within the archive.
PS /> Get-RarEntry .\archive.rar -Include *.txt | Expand-RarEntry -Destination .\extractedThis example extracts only the .txt files from a RAR archive to the specified .\extracted directory (created automatically if needed).
PS /> Get-RarEntry .\archive.rar -Exclude *.txt | Expand-RarEntryThis example extracts everything except .txt files from archive.rar to the current directory, preserving the original structure.
PS /> Get-RarEntry .\archive.rar -Include *.txt | Expand-RarEntry -ForceThis example extracts the .txt files and overwrites any existing files with the same name in the destination due to the -Force switch.
PS /> Get-RarEntry .\archive.rar -Exclude *.txt | Expand-RarEntry -PassThru
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2026-09-29 2:00 PM folder1
-a--- 2026-09-29 2:00 PM 2048 image.pngThis example extracts everything except .txt files and uses -PassThru to output FileInfo and DirectoryInfo objects for the extracted items. By default, the cmdlet produces no output.
PS /> Get-RarEntry .\archive.rar -Include secret.txt | Expand-RarEntry -Password (Read-Host -AsSecureString)This example demonstrates how to expand an encrypted RAR entry using Read-Host -AsSecureString to provide the password.
Note
If an entry is encrypted and no password is supplied, the cmdlet will prompt for one interactively.
The destination directory where RAR entries are extracted. If not specified, entries are extracted to their relative path in the current directory, creating any necessary subdirectories.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOverwrites existing files in the destination directory. Without -Force, attempting to extract an entry over an existing file results in a non-terminating error.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe RAR entries to extract. These are instances of RarEntry output by the Get-RarEntry cmdlet.
Note
This parameter accepts pipeline input from Get-RarEntry. Binding by property name is also supported.
Type: RarEntry[]
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseOutputs System.IO.FileInfo and System.IO.DirectoryInfo objects for the extracted entries. By default, the cmdlet produces no output.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the password as a SecureString to extract an encrypted RAR entry.
Note
If an entry is encrypted and no password is supplied, the cmdlet will prompt for one.
Type: SecureString
Parameter Sets: (All)
Aliases:
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 instances of RarEntry from Get-RarEntry to this cmdlet.
By default, this cmdlet produces no output.
When the -PassThru switch is used, the cmdlet outputs FileInfo and DirectoryInfo objects representing the extracted items.