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.
create-7zip "$storageDir\wordpress\*" "$storageDir\wordpress.zip"
将包括文件和子文件夹。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.