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 xyz.zip
# specify a output dir
Expand-Archive xyz.zip  ~/out/

example script:

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

untar, ungzip, gunzip

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

Extract 7z

You have to install 7z. (❮https://www.7-zip.org/❯)

# extract to full paths of items
7z x filename

Extract lzip (.lz)

You have to install lzip. At https://www.nongnu.org/lzip/lzip.html

# extract .lz file
lzip -d filename

PowerShell: archive file, compression