Compress-Zip Cmdlet
Parameters Output Objects Configuration Settings
The Compress-ZIP cmdlet implements a compressor for ZIP, GZIP, JAR, TAR, and ZIP SFX.
Syntax
Compress-Zip [parameters]
Remarks
The format for compression is specified by the Format parameter.
The Input parameter should be set to the list of files/folders to include in the archive. The Output parameter should be set to the name and file path of the resulting archive.
For Zip, the cmdlet uses the Deflate algorithm specified in RFC 1951 for compression, and writes output compatible with PKZip, WinZip, etc.
The gzip Format is used only to archive a single file. Accordingly, the operation of the cmdlet for this format is simpler than that of the other formats.
For Jar files, the operation of the cmdlet is similar to that of the Zip Format. .class and other files may be added into a .jar file, and then may be imported into Java code or executed by a JVM.
When compressing Tar files, the interface is identical to that of the Zip format and is the same whether gzip compression is used or not.
The ZipSFX Format implements a PKZip-compatible Zip compressor to create a self-extracting archive which will run natively on Windows platforms.
The cmdlets support pipeline input for some of their parameters. Prebuilding an object and piping it to the cmdlet is very useful, but should be used with caution to prevent security conflicts. Steps have been taken to decrease the risk of a possibly accidental pipe to the cmdlet, for instance, the Credential parameter cannot be piped to the cmdlet and must be specified manually.
# compress the contents of a folder into a zip file and password protect the file
Compress-Zip -Input C:\temp\* -Output C:\tesmpzip34.zip -Password mypassword
# archive the contents of a folder to a tar archive
Compress-Zip -Input C:\temp\* -Output C:\temptar.tar -Format tar
# create a gzipped tar of a specific file
Compress-Zip -Input C:\temptar.tar -Output C:\temptar.tar.gz -Format gzip
Parameter List
The following is the full list of the parameters of the cmdlet with short descriptions. Click on the links for further details.
LogFile | The location of a file to which debug information is written. |
BannerText | Optional banner text to show before the self-extraction starts. |
CompressionLevel | The compression level. |
Config | Specifies one or more configuration settings. |
EncryptionAlgorithm | The algorithm used to encrypt files written to the archive. |
FileCompressedName | Specifies the path and filename of the file in the archive. |
Format | The format of the compression used. |
Input | The files to be included in the archive. |
LogFile | The location of a file to which debug information is written. |
Output | The archive file. |
Overwrite | Whether or not to overwrite the archive. |
Password | The password for the zip archive. |
Recurse | Whether or not to recurse into subdirectories. |
ZipComment | The archive comment. |
Output Objects
The following is the full list of the output objects returned by the cmdlet with short descriptions. Click on the links for further details.
ZipFile | Returned after creation of a zip file. |
Configuration Settings
The following is a list of configuration settings for the cmdlet with short descriptions. Click on the links for further details.
UseBackgroundThread | Whether threads created by the cmdlet are background threads. |
UseInternalSecurityAPI | Tells the cmdlet whether or not to use the system security libraries or an internal implementation. |