PowerShell zip files and folder

/ By Arjun / Published on January 26, 2021

In the PowerShell window, type in the following command:

Make sure to change to the actual path of the file you want to zip and with the location where you want to save the file.

Compression Level

There are three types of compression level.

  • Fastest − Uses the fastest compression to reduce the processing time. It can lead to larger file size.
  • Optimal − Normal compression level. Processing time depends on the size of the file. This is the default compression level if you don’t use the compression parameter.
  • NoCompression − Doesn’t compress the source files. This means the size of the actual folders and files are the same after the zipped only there is no compression ratio.

Compress files to create an archive file

*.vsd is wildcard here for multiple files with the same extension.

compress Root directory and below sub-directories and files

compress all the files and sub-directories below the root “SourceLocation” folder

compress only the files in the “SourceLocation” folder.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
8 months ago

Hi Arjun

Great article, I have a question. Hope you can answer. Here’s my code that zips all the folders into a single folder.

What I want to do it to copy this zip folder and send it to a shared network network location which should be a parameter.

I've tried many different stuff but haven't gone through yet. I just tried:

8 months ago
Reply to  Arjun

Thanks for the reply Arjun, I figured it out.

4 months ago

Hi, maybe you also know how to compress a root directory but only with all *.pdf files of it? So I have a folder: myFolder {name1.pdf,name1.xml,name2.pdf,name2.xml} and I want my zip to look lie: result.zip{myFolder{name1.pdf,name2.pdf}. Any idea?

Would love your thoughts, please comment.x