More New Stuff in PowerShell V5: Expand and Compress Archive Cmdlets

With the July release of PowerShell V5 Preview (Download links are 1/3 of the way down on the DSC download page), there are some new things that have been added that are worth talking about.

Here are the direct download links for the July Preview of PowerShell V5:

If you recall, I talked about some of the new things in PowerShell V5 Preview here and here but now I am going to go over one of the new items that have been added to this release:

Archive Cmdlets

Finally we have cmdlets which allow us to create a zip archive to zip and unzip files.

  • Compress-Archive


From what we can see with the help file on Compress-Archive, there are 2 parameter sets that are based on Path and LiteralPath parameters. We have an –Update parameter which allows us to add to an existing archive file. We can also set the CompressionLevel (Fastest, NoCompression or Optimal (Default Value)) for the archive.

Let’s give it a quick run to see what happens:

Get-ChildItem | 
Compress-Archive -DestinationPath 'C:\users\boe.prox\Desktop\' -Verbose



Note: Using just a folder without a full path name causes the script to throw errors


It still creates an archive, but it seems to move it to the parent folder above my current path. It probably should just use the current path if none is given.


This feels like a bug to me and should handle the current directory instead of shipping it somewhere else and throwing errors. If you think so to, feel free to vote this up:

If you don’t use the –Update parameter and try to add something to an existing archive, an error will be thrown reminding you to use –Update.


Pretty much all there is to that. Now let’s check out the second cmdlet for archives.

  • Expand-Archive


Again, we have 2 parameter sets for Path and LiteralPath. We just have to supply the archive file and a destination path for the archive folder. What I am curious to see is if I do not supply a DestinationPath which requires a folder name and if the folder that everything is unzipped to will be the name of the archive.

Expand-Archive .\ -DestinationPath $Pwd -Verbose


It appears that it will not create a folder based on the archive name and will instead attempt to unzip the file to the existing directory. If the file exists, you will see errors stating to use the –Force parameter, which makes sense.


Now lets run this and specify an actual folder name (but one that doesn’t exist).

Expand-Archive .\ -DestinationPath 'UnzippedArchive' -Verbose



Well, it didn’t like that at all. I guess we have to specify an existing folder in order for this to work. At first I wasn’t sure how I liked that, but copy-item and move-item do not auto create directories if they do not exist, so I would expect this cmdlet to do the same.



Well, that is it for checking out the new cmdlets: Compress-Archive and Expand-Archive! I will look to dive into another new addition to PowerShell V5 July Release in the coming days. Stay tuned!

This entry was posted in powershell and tagged , , , , , , . Bookmark the permalink.

6 Responses to More New Stuff in PowerShell V5: Expand and Compress Archive Cmdlets

  1. Pingback: ZIP Kompression mit der PowerShell; eine Übersicht. › Windows PowerShell Community

  2. webmastir says:

    This is sweet.

  3. JJ says:

    Oh this is sweet.

  4. I don’t see a link on to PowerShell V5 July Release. Can you provide a working URL?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s