I can't quite remember where I found the answer that led me to use this Powershell snippet, but I've been using this script to zip a folder and the files contained within it:
param (
[string]$ZipFrom,
[string]$ZipTo
)
function Add-Zip
{
param([string]$zipfilename)
if(-not (test-path($zipfilename)))
{
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
foreach($file in $input)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
}
If(Test-path $ZipTo) {Remove-item $ZipTo}
dir $ZipFrom -Recurse | Add-Zip $ZipTo
Not sure what I'm missing, but it seems like it's zipping HALF of the files within the folder. I just tried this on a folder with 62 files in it, and I ended up with a zip archive with 31 files in it.