Last active
November 19, 2015 16:28
-
-
Save seibar/8dc41cee2c9ccc907e35 to your computer and use it in GitHub Desktop.
Powershell Zip
This file contains hidden or 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
| # Usage: | |
| # PS C:\pathToScript> Zip.ps1 C:\directory\to\zip C:\zipFileName.zip | |
| [CmdletBinding(DefaultParameterSetName = 'None')] | |
| param | |
| ( | |
| [String] [Parameter(Mandatory = $true)] | |
| $SourceDirectory, | |
| [String] [Parameter(Mandatory = $true)] | |
| $OutputFilename | |
| ) | |
| # Based on http://stackoverflow.com/a/13302548/357 | |
| function ZipFiles( $sourcedir, $zipfilename ) | |
| { | |
| Add-Type -Assembly System.IO.Compression.FileSystem | |
| $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal | |
| [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false) | |
| } | |
| ZipFiles $SourceDirectory $OutputFilename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment