How to include files and folders using 7zip powershell

I am trying to make my script resource encrypted multiple files and folders. At the moment, I can make my script either zip all the files (without any folders), or zip up all the files with the folders included, but on the wrong path. For example, if I have a folder named wordpress with files and several subfolders. I need my zip file for wordpress.zip, and all the files and subfolders are in the root of this zip, and not in \ wordpress \ files. *

Any help would be greatly 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" 

In the above example, there will only be zip files inside my target folder, I also need to include subfolders there.

+6
source share
1 answer
 create-7zip "$storageDir\wordpress\*" "$storageDir\wordpress.zip" 

will include files and subfolders.

+8
source

Source: https://habr.com/ru/post/916693/


All Articles