I'm using Compress-Archive as follows to create a zip file that contains 3 files and 2 directories (and all of their sub-directories)
Compress-Archive -CompressionLevel Fastest -Force -DestinationPath ./My.zip -Path .\foo.ini,
.\bar.exe,
.\README.TXT,
.\dir1,
.\dir2
Unfortunately, it is extremely slow. I'd like to use 7-Zip (which is faster) to create a zip file. I've been trying to use the Powershell add-on Compress-7Zip
to do the compression instead. Also unfortunately, I can't figure out how to use Compress-7Zip
to take just the specified files. I thought if I could populate a variable with all of the files I could pipe into Compress-7Zip
.
$stuff = ??? .\foo.ini,
.\bar.exe,
.\README.TXT,
.\dir1,
.\dir2
#$stuff now contains 3 txt files in the root and the complete contents
#dir\ and \dir2 with their paths
$stuff | Compress-7Zip -Format Zip -ArchiveFileName .\my.zip
How can I use Get-Child-Item (or something else) to get the directory structure into $stuff?
Or if you have another suggestion for creating this zip using a better compression method than what Compress-Archive, I'm all ears.