---
title: "Introducing PowerShell Unzip and Zip Commands on Archives"
description: "Tired of clicking menus and buttons to manage ZIP files? Learn how PowerShell Unzip and PowerShell Zip can work on archives in this tutorial!"
canonical: "https://adamtheautomator.com/powershell-unzip/"
---

# Introducing PowerShell Unzip and Zip Commands on Archives

> Tired of clicking menus and buttons to manage ZIP files? Learn how PowerShell Unzip and PowerShell Zip can work on archives in this tutorial!

Source: https://adamtheautomator.com/powershell-unzip/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Introducing PowerShell Unzip and Zip Commands on Archives](https://adamtheautomator.com/wp-content/uploads/2021/09/How-to-Zip-and-Unzip-Files-with-PowerShell.jpg)

# Introducing PowerShell Unzip and Zip Commands on Archives

[![](https://secure.gravatar.com/avatar/4147968aa2332aa682bcebf295e4e9d0eb2672dee3d9ae0523a00ac51e7d6017?s=192&d=mm&r=g)Bill Kindle](https://adamtheautomator.com/author/bill/)23 September 20215 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Compressing Files with the Compress-Archive Command](#compressing-files-with-the-compress-archive-command)
*   [Compressing Files One at a Time](#compressing-files-one-at-a-time)
*   [Compressing All Files From a Folder](#compressing-all-files-from-a-folder)
*   [Defining Compression Levels](#defining-compression-levels)
*   [Adding Files to a Compressed File](#adding-files-to-a-compressed-file)
*   [Expanding Zip Files with the Expand-Archive Command](#expanding-zip-files-with-the-expand-archive-command)
*   [Listing Compressed Files via .NET](#listing-compressed-files-via-net)
*   [Powershell Unzip and Zip Files with 7Zip4PowerShell Module](#powershell-unzip-and-zip-files-with-7zip4powershell-module)
*   [Conclusion](#conclusion)

Compressing or expanding single or multiple files is a valuable skill that all PowerShell users can immediately use. Perhaps you want to size down your files a bit or just keeping files in one place other than a folder. If so, let PowerShell unzip and zip your files by running commands.

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

In this tutorial, you are going to learn many ways to zip and unzip files in PowerShell.

Ready? Let’s start rolling!

## Prerequisites

The examples in this tutorial will use PowerShell 7.1.x. The commands will also work on Windows PowerShell 5.1.

Related:[How to Manage Zip Files in Linux](https://adamtheautomator.com/unzip-files-in-linux/)

## Compressing Files with the `Compress-Archive` Command

You have been using applications to compress and archive files for years by clicking on a GUI. But did you know you can do the same task in [PowerShell](https://adamtheautomator.com/basic-powershell-commands/)? Using the [`Compress-Archive`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.1) command, you can zip up files with ease.

Imagine for a moment that you have a few files to send to a customer. The files are in a folder on your computer that might resemble the screenshot below. This tutorial references these files for running commands, but you can use any files available at your disposal.

![Viewing List of Files in a Folder](https://adamtheautomator.com/wp-content/uploads/2021/09/image-188.png)

Viewing List of Files in a Folder

### Compressing Files One at a Time

Before you can compress a single file, you need two things; a source and a destination.

Open [PowerShell as administrator](https://adamtheautomator.com/powershell-run-as-administrator/), then run the command below to compress a single file (`widget.png`) to a ZIP file (`archive.zip`). The `-Path` parameter tells the `Compress-Archive` command the location of the file to compress. While the `-DestinationPath` tells where to archive the file.

```powershell
 Compress-Archive -Path widget.png -DestinationPath archive.zip
```

> _Compress multiple files at once by separating them with a comma e.g. `Compress-Archive -Path widget.png,file1.txt,manual.pdf -DestinationPath archive.zip`_

### Compressing All Files From a Folder

If you have organized files in a folder that you want to compress in one go, use wildcard characters like an asterisk (\*) to signify all the files is ideal.

Run the command below to compress and archive (`Compress-Archive`) all files (`*`) from the `C:\Demo` folder to the `archive.zip` file.

```powershell
Compress-Archive -Path 'C:\Demo\*' -DestinationPath archive.zip
```

Now perhaps you only want to compress files that are of the same type. If so, combine the wildcard symbol with the extension of the files to compress.

Run the command below to compress and archive all log files (`*.log`) to the `archive.zip` file.

```powershell
Compress-Archive -Path '*.log' -DestinationPath archive.zip
```

### Defining Compression Levels

With the previous examples, you’ve been compressing files with the default [compression level](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.1#parameters) (Optimal), but let’s cover the different compression levels. Compression levels define how much compression applies when you create an archive file.

Below are three compression level parameters you can choose from:

*   Optimal (Default) – Compression time depends on the number and size of files.
*   `Fastest` – The fastest compression method, resulting in larger file sizes.
*   `NoCompression` – Leaves file sizes intact.

Run any of the commands below to see how each compression level works. Each command compresses log (`*.log`) files to the `archive.zip` file.

```powershell
# Optimal (Default compression level) 
Compress-Archive -Path '*.log' -DestinationPath archive.zip
# Fastest compression level
Compress-Archive -Path '*.log' -DestinationPath archive.zip -CompressionLevel Fastest
# No compression
Compress-Archive -Path '*.log' -DestinationPath archive.zip -CompressionLevel NoCompression
```

### Adding Files to a Compressed File

Now, if you forgot to add a file to an archive, don’t panic! There is an `-Update` parameter you could use to add files to an existing archive.

Run the command below to add (`-Update`) your preferred file (`manual.pdf`) to the existing archive (`archive.zip`).

```powershell
Compress-Archive -Update -Path 'manual.pdf' -DestinationPath archive.zip
```

> _The `-Update` parameter tells the `Compress-Archive` command to overwrite an existing file with a new one automatically. But be careful when you add files to the archive. You don’t want to overwrite your file with an old one._

Related:[How to Manage ZIP Files in Python](https://adamtheautomator.com/python-zip/)

## Expanding Zip Files with the `Expand-Archive` Command

Similar to how you compress files, expanding an archive is not all that different. You’ll need to run the [`Expand-Archive`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.1) command while specifying the source and destination path. The `Expand-Archive` command lets you extract archived files.

Run the `Expand-Archive` command below to extract the contents of the `archive.zip` file. Since no destination path is specified, the command creates a destination folder in the working directory. The destination folder is named the same as the archive file (_archive_).

```powershell
Expand-Archive -Path archive.zip -DestinationPath C:\Demo\Archive
```

> _Add the `-Force` parameter to suppress all confirmation prompts._

> _If you use `Expand-Archive` with archives that contain files that were not compressed in a [UTF-8 format](https://www.periodni.com/unicode_utf-8_encoding.html), the extracted filenames could be different than the source._

## Listing Compressed Files via .NET

There’s no way with the previous two cmdlets you’ve learned about that will allow you to peek inside an archive without expanding it first. Perhaps you’ve forgotten which files you already compressed. If so, extracting everything just to verify which files you already archived would be a waste of time.

The better way to peek into an archive is by using the [.NET ZipFile class](https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile?view=net-5.0). As a part of the [System.IO.Compression namespace,](https://docs.microsoft.com/en-us/dotnet/api/system.io.compression?view=net-5.0) the .NET ZipFile class contains a method called `OpenRead(String)` that enables you to peek inside an existing archive.

Run the command below to read each file in the _archive.zip_ file (`OpenRead("$pwd\archive.zip")`) and assign the results to the `$archive` variable.

```powershell
# (pwd) - working/current directory
$archive = [System.IO.Compression.ZipFile]::OpenRead("$pwd\archive.zip")
```

Now run the command below to list each file assigned in the `$archive` variable by name (`Select-Object -Property Name`)

```powershell
$archive.Entries | Select-Object -Property Name
```

Below, you can see the command listed each compressed file in the _archive.zip_ file.

![Listing Compressed Files by Name without Extracting Them](https://adamtheautomator.com/wp-content/uploads/2021/09/image-189.png)

Listing Compressed Files by Name without Extracting Them

If you also prefer to view each file’s properties instead, references the `Entries` property instead.

```powershell
$archive.Entries
```

You’ll now see the properties of every file in the archive, similar to the image shown below.

![Listing Compressed Files and their Properties without Extracting Them](https://adamtheautomator.com/wp-content/uploads/2021/09/image-190.png)

Listing Compressed Files and their Properties without Extracting Them

## Powershell Unzip and Zip Files with 7Zip4PowerShell Module

A tutorial about compressing and expanding zip archives wouldn’t be complete without mentioning another compression module, [7Zip4PowerShell](https://www.powershellgallery.com/packages/7Zip4Powershell/2.0.0). 7Zip4PowerShell contains some enhanced capabilities that may make it a feature-rich choice.

For example, you previously learned about .NET classes and methods. With the 7Zip4PowerShell module, the command to list archived files is less complicated.

Run the `Get-7Zip` command below to list all the files inside the _archive.zip_ file (`-ArchiveFileName .\archive.zip`).

> _With 7Zip4PowerShell, the `Compress-7Zip` cmdlet gives you more options for different types of archives, such as Tar, GZip, BZip2, SevenZip, XZ, and Zip._

![Listing Compressed Files by Running Get-7Zip Command ](https://adamtheautomator.com/wp-content/uploads/2021/09/image-191.png)

Listing Compressed Files by Running Get-7Zip Command

> _You can also view information about the archive itself by running the `Get-7ZipInformation` command, like this: `Get-7ZipInformation -ArchiveFileName archive.zip`. The command lists all properties of the archive.zip file._

## Conclusion

By now, you’ve learned how PowerShell unzip and zip files with built-in commands and with the 7Zip4PowerShell module. This newfound knowledge comes in handy whether you’re sizing down your files or when you’re just sending many files over as one. But is that all PowerShell has to offer?

Instead of running commands as a rudimentary backup solution, why not make a script to archive files and automatically email or transfer them to long-term storage?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-unzip%2F&text=Introducing%20PowerShell%20Unzip%20and%20Zip%20Commands%20on%20Archives)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-unzip%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-unzip%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
