简体   繁体   中英

Im stuck on a powershell script that has to compress all files from multiple subfolders to a destination folder

Im stuck on a Powershell script that has to compress all files recursively from multiple subfolders to a destination folder.

Something like this:

From:

c:\backup\user\documents\\*  
c:\backup\user2\\*  
c:\backup\new\program\\*  

To:

x:\backupfolder\file1.zip

According to PS documentation, you can use the function Compress-Archive to do this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-6

$compress = @{
Path= "c:\backup\user\documents*", "c:\backup\user2*", "c:\backup\new\program*"
CompressionLevel = "Fastest"
DestinationPath = "x:\backupfolder\file1.zip"
}
Compress-Archive @compress

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM