I'm looking for the equivalent PowerShell command for:
tar -zcvf tar-archive-name.tar.gz source-folder
Does such a one-liner exist that creates a zip file from a folder recursively adding the contents of the source-folder
, that doesn't require a 3rd party library like 7-zip?
Starting with Powershell 5, you can use the built-in Compress-Archive
command:
Compress-Archive -Path source-folder -DestinationPath archive-name.zip
If you are using powershell prior to version 5, there is no one liner solution without a third party program like 7-zip. However, you can leverage the built in zipping capabilities of windows explorer as exposed through the COM Shell object to build your own powershell function to do this. This page outlines the details on how to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With