PowerShell: Extract zip tar 7z lz

By Xah Lee. Date: . Last updated: .

Here's how to decompress, unarchive, extract, zip, tar, 7z etc files.

unzip

# unzip to current dir
Expand-Archive myfile.zip
# unzip to current dir, do not create a parent folder
Expand-Archive myfile.zip -PassThru
# unzip to a destination dir
Expand-Archive myfile.zip ~/out/

example script:

# unzip all *.zip files to a dir named x
dir -Recurse -Filter "*.zip" | Expand-Archive -PassThru -DestinationPath x

untar, ungzip, gunzip

Windows 10 has BSD tar builtin, at C:/Windows/system32/tar.exe

Extract 7z

install 7z at https://www.7-zip.org/

# extract to full paths of items
7z x myfile.7z

Extract lzip (.lz)

install lzip at https://www.nongnu.org/lzip/lzip.html

# extract .lz file
lzip -d myfile.lz

extract archived files, unzip tar 7z lz etc

PowerShell. Archive file, compression