Last active
January 20, 2021 04:23
-
-
Save stefanteixeira/0428e8ade6be09d94b90 to your computer and use it in GitHub Desktop.
PowerShell script to compress a directory to a .zip file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I am trying to compress zip files using your script and its not working for me. It gives following error.