Powershell module for creating and extracting 7-Zip archives supporting Powershell's WriteProgress
API.
Note
Please note that this repository is not maintained anymore. I've created it a couple of years ago to fit my own needs (just compressing a single folder). I love that lots of other users find my package helpful.
I really appreciated if you report issues or suggest new feature. However, I don't use this package myself anymore, and I don't have the time to maintain it appropriately. So please don't expect me to fix any bugs. Any Pull Request is welcome though.
The syntax is simple as this:
Expand-7Zip
[-ArchiveFileName] <string>
[-TargetPath] <string>
[-Password <string>] | [-SecurePassword <securestring>]
[<CommonParameters>]
Compress-7Zip
[-ArchiveFileName] <string>
[-Path] <string>
[[-Filter] <string>]
[-OutputPath] <string>
[-Format <OutputFormat> {Auto | SevenZip | Zip | GZip | BZip2 | Tar | XZ}]
[-CompressionLevel <CompressionLevel> {None | Fast | Low | Normal | High | Ultra}]
[-CompressionMethod <CompressionMethod> {Copy | Deflate | Deflate64 | BZip2 | Lzma | Lzma2 | Ppmd | Default}]
[-Password <string>] | [-SecurePassword <securestring>]
[-EncryptionMethod <ZipEncryptionMethod> {ZipCrypto | Aes128 | Aes192 | Aes256}]
[-CustomInitialization <ScriptBlock>]
[-TempFolder <string>]
[-IncludeHidden]
[-IncludeSystem
[-EncryptFilenames]
[-VolumeSize <int>]
[-FlattenDirectoryStructure]
[-SkipEmptyDirectories]
[-PreserveDirectoryRoot]
[-DisableRecursion]
[-Append]
[<CommonParameters>]
Get-7Zip
[-ArchiveFileName] <string[]>
[-Password <string>] | [-SecurePassword <securestring>]
[<CommonParameters>]
Get-7ZipInformation
[-ArchiveFileName] <string[]>
[-Password <string>] | [-SecurePassword <securestring>]
[<CommonParameters>]
It works with both x86 and x64 and uses SevenZipSharp as a wrapper around 7zip’s API.
Jason Fossen wrote the article PowerShell 7-Zip Module Versus Compress-Archive with Encryption where he describes some usage scenarios with 7Zip4PowerShell.
7Zip4Powershell is published at PowerShell Gallery.
Compress-7Zip
accepts a script block for customization. The script block gets passed the current
SevenZipCompressor
instance. E.g. you can set the multithread mode this way:
$initScript = {
param ($compressor)
$compressor.CustomParameters.Add("mt", "off")
}
Compress-7Zip -Path . -ArchiveFileName demo.7z -CustomInitialization $initScript
A list of all custom parameters can be found here.
EncryptionMethod
to Compress-7Zip
TempFolder
parameter to Compress-7Zip
(requested in #78)ArchiveFileName
(#63 and #65, contributed by @iRebbok)PreserveDirectoryRoot
for Compress-7zip
.
(#57, contributed by @kborowinski)OutputPath
for Compress-7Zip
(#60, contributed by @iRebbok)CustomInitialization
parameter for Expand-7Zip
, will be removed in future versions.January 25, 2017
SecurePassword
parameter of type SecureString
to all cmdlets. (#34, #36)October 27, 2016
October 16, 2016
Format
is not specified, it is inferred from the file extension of ArchiveFileName
(#24, proposed by @onyxhat)VolumeSize
to specify the colume size for Compress-7Zip
(#25, proposed by @rgel)FlattenDirectoryStructure
, SkipEmptyDirectories
, and DisableRecursion
to Compress-7Zip
(#27, contributed by @itmagination)Append
to Compress-7Zip
to append files to an existing archive (#30, inspired by @itmagination)June 15, 2016
Get-7ZipInformation
cmdletCompress-7Zip
(previously it was PPMd, for whatever reason) (#11)Get-7Zip
(#15)WriteDebug
instead of Write
of logging (#13)June 5, 2016
-EncryptFilenames
to Compress-7Zip
(#10, requested by @JasonFossen)May 29, 2016
Get-7Zip
to get a list of files in an archive (#9, contributed by @gigi81)30 March, 2016
Password
parameter to both Compress-7Zip
and Expand-7Zip
(#8)I've written and maintaining the module just for fun and to serve my own needs. If it's useful for you too, that's great. I don't demand anything in return.
However, if you like this module and feel the urge to give something back, a coffee or a beer is always appreciated. Thank you very much in advance.