PowerShell 压缩子文件夹


$SourcePath = "D:ReportsDeskReports2016Q2"
$ArchivePath = "D:ReportsDeskReportsArchive_2016Q2"
$7ZipPath = "D:data7-Zip7z.exe"

Get-ChildItem -Path $SourcePath -Recurse | Where-Object {$_.PSIsContainer} | ForEach-Object {
$directoryFullName = $_.FullName
$directoryName = $_.Name
Invoke-Expression -Command "$7ZipPath a $ArchivePath$directoryName.zip $directoryFullName*"
}

原文地址:https://www.cnblogs.com/bi-info/p/6370160.html