Skip to content

Instantly share code, notes, and snippets.

@stefanteixeira
Last active January 20, 2021 04:23
Show Gist options
  • Select an option

  • Save stefanteixeira/0428e8ade6be09d94b90 to your computer and use it in GitHub Desktop.

Select an option

Save stefanteixeira/0428e8ade6be09d94b90 to your computer and use it in GitHub Desktop.
PowerShell script to compress a directory to a .zip file
$source = "C:\Path\To\Directory"
$destination = "C:\Path\To\Zip\file.zip"
If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($Source, $destination)
@nmanjos
Copy link
Copy Markdown

nmanjos commented Aug 24, 2018

This was Helpfull, thanks !

@parthvora25
Copy link
Copy Markdown

Hi,
I am trying to compress zip files using your script and its not working for me. It gives following error.
error

@john2893
Copy link
Copy Markdown

john2893 commented Nov 8, 2018

Thank you! That worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment