PowershellPack: copy-tozip
The PowerShell pack is part of the Windows 7 resource kit and is also available as a separate download. The Filesystem module contains the following functions:
Copy-ToZip
Get-DuplicateFile
Get-FreeDiskSpace
Get-SHA1
Mount-SpecialFolder
New-Zip
Rename-Drive
Resolve-ShortcutFile
Start-FileSystemWatcher
Copy-ToZip does what it says and copies files into a .zip archive. If the archive doesn’t exist it will create the archive. To copy all the files in a directory
Get-ChildItem -Exclude *.zip | where{!$_.PSIsContainer} | Copy-ToZip -ZipFile test.zip
I just want the files so use where to filter out subfolders. I exclude the zip file itself otherwise an error is generated. Copy-toZip has a –HideProgress parameter that hides the progress bar if required.
The function doesn’t provide the functionality of a fully fledged zip utility but for zipping up a bunch of files its good. Easy to use in a script as well.