Wednesday, May 8, 2019

Zip it Good - CLI ZIP with Powershell

Compress-Archive with Powershell

Compress-Archive
        [-Path] <String[]>
        [-DestinationPath] <String>

Example

Compress-Archive -Path <Files to compress(comma seperated)> -DestinationPath Output.Zip


Files Intended to be zipped into one folder



The above command, "Compress-Archive -Path .\* -DestinationPath '.\CLIzip.ZIP", compresses all in the current folder and sends to zip folder 



















The zip folder was created






Expand-Archive with Powershell

Expand-Archive [-Path] <String> [[-DestinationPath] <String>]

Example

Expand-Archive -Path <Zippedfolder.Zip> -DestinationPath <Output Path>

Decompressing CLIzip.zip and using the -Force in case files are already there


Original files have been unzipped






























In conclusion, this may be a handy way to zip up files for sending or storage.  And/or noticing the Compress and Expand Archive powershell commands that are associated with zipping folders if seen in PS logs.  

Done via command line.


--Bryan











No comments:

Post a Comment