PowerShell: unzip, untar

By Xah Lee. Date: . Last updated: .

unzip

Expand-Archive xyz.zip

Expand-Archive -Path c:/Users/xah/xyz.zip -DestinationPath  c:/Users/xah/out/

Expand-Archive -LiteralPath c:/Users/xah/xyz.zip -DestinationPath  c:/Users/xah/out/

example script:

# unzip all nb.zip files it a out dir
dir -Recurse -Include "*nb.zip" | Expand-Archive -PassThru -DestinationPath out

tar/untar

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

# extract .tar file
tar xvf some.tar

# extract .tar.gz (.tgz) file
tar xvfz some.tar.gz

# extract .tar.bz2 file
tar xvfj some.tar.bz2

# extract .tar.xz file
tar xvfJ some.tar.xz
# create tar file
tar cvf dirname.tar dirname

tar -h for help. For more detail see Linux: Compression How-to: tar gzip bzip2 xz 7zip rar zip

PowerShell

How-to

Advanced

Script Examples