Zip a File or Folder in Powershell

11/19/2015 9:27:02 PM

Using Windows 8+, you can use Powershells built in compression functionality to compress a folder or file.

$source = "C:\Name Of Folder to Compress"

$destination = "C:\NameOfCompressedFolder.zip"

If(Test-path $destination) {Remove-item $destination}

Add-Type -assembly "system.io.compression.filesystem"

[io.compression.zipfile]::CreateFromDirectory($Source, $destination)