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:

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: https://connect.microsoft.com/PowerShell/feedbackdetail/view/954121/v5-july-preview-compress-archive-should-default-to-current-directory-if-fully-qualified-path-given-for-destination-path

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.

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).

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!