In the previous blog post we have seen how to extract a ZIP file.
But what about, how you can create a zip file by using PowerShell.
It's simple again, by using the Compress-Archive cmdlet. The syntax of Compress-Archive cmdlet is simple, provide the -Path of the folder which you want to compress, then provide the -DestinationPath of your .zip file and then set a -CompressionLevel, and after that hit enter.
Compress-Archive -CompressionLevel Optimal -Path C:\temp\Data\
In the the above command, I have set the -compressionLevel to Optimal , and then provided the -path of my folder which I wan to zip and then the destination path of new zip file which in aman.zip. And hit enter, in the below screenshot you can see that it has started creating a zip file.
In the below folder you can see, that our zip file is successfully created. Yayyy!!!!!
Thanks for the reading blog post.
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube” channel
for PowerShell video tutorials. You can download all of my scripts from “Microsoft