이 압축합니다. \ 내용에에. \ out.zip System.IO.Packaging.ZipPackage으로 다음 예제 here
$zipArchive = $pwd.path + "\out.zip"
[System.Reflection.Assembly]::Load("WindowsBase,Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
$ZipPackage=[System.IO.Packaging.ZipPackage]::Open($zipArchive, [System.IO.FileMode]"OpenOrCreate", [System.IO.FileAccess]"ReadWrite")
$in = gci .\in | select -expand fullName
[array]$files = $in -replace "C:","" -replace "\\","/"
ForEach ($file In $files) {
$partName=New-Object System.Uri($file, [System.UriKind]"Relative")
$part=$ZipPackage.CreatePart($partName, "application/zip", [System.IO.Packaging.CompressionOption]"Maximum")
$bytes=[System.IO.File]::ReadAllBytes($file)
$stream=$part.GetStream()
$stream.Write($bytes, 0, $bytes.Length)
$stream.Close()
}
$ZipPackage.Close()
나는 이것이 당신의 선택을 설명한다고 생각한다 : http://richardspowershellblog.wordpress.com/2007/06/02/powershell-and-compressed-files/ – David
대단히 감사합니다! 이것은 깨끗하고 쉬운 해결책이었습니다. 이 스레드에 걸려 넘어 질 수있는 다른 사람을위한 지시. http://pscx.codeplex.com/downloads 파일을 추출한 다음 디렉토리를 C : \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ Modules로 이동합니다. 그런 다음 다음 명령을 실행하여 모듈을 가져옵니다. Import-Module Pscx – TechDawg270