How to include files and folders with 7zip powershell

7zip, powershell, zip

Solution

create-7zip "$storageDir\wordpress\*"  "$storageDir\wordpress.zip"

will include files and subfolders.

Problem

Im trying to make my powershell script zip up a few files and folders. At the moment I can make my script either zip all files (with no folders included), or zip all files with folders included but to the wrong path. An example would be if I have a folder named wordpress with files and a few subfolders. I need my zip file to be wordpress.zip, with all files and subfolders being in the root of that zip as opposed to \wordpress\files.* Any help would be appreciated. Here is my code so far ``` function create-7zip([String] $aDirectory, [String] $aZipfile){ [string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe"; [Array]$arguments = "a", "-tzip", "$aZipfile", "$aDirectory"; & $pathToZipExe $arguments; } create-7zip "$storageDir\wordpress\*.*" "$storageDir\wordpress.zip" ``` The above example will only zip files inside of my target folder, I need it to include the subfolders as well.

Original source