PowerShell Logo Small

Compress-Archive



This is the built-in help made by Microsoft for the command 'Compress-Archive', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Creates a new archive, or zipped file, from specified files and folders.

SYNTAX


Compress-Archive [-Path] <String[]> [-DestinationPath] <String> [-CompressionLevel <String>] [-Update] [-Confirm] [-WhatIf] [<CommonParameters>]
Compress-Archive [-DestinationPath] <String> [-CompressionLevel <String>] [-Update] -LiteralPath <String[]> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Compress-Archive cmdlet creates a new zipped (or compressed) archive file from one or more specified files or folders. An archive file allows multiple files to be
packaged, and optionally compressed, into a single zipped file for easier distribution and storage. An archive file can be compressed by using the compression algorithm
specified by the CompressionLevel parameter.



<

RELATED LINKS


Online Version: http://go.microsoft.com/fwlink/?LinkID=393252

REMARKS

<

Examples


Example 1: Create a new archive file

PS C:\>Compress-Archive -LiteralPath C:\Reference\Draftdoc.docx, C:\Reference\Images\diagram2.vsd –CompressionLevel Optimal -DestinationPath C:\Archives\Draft.Zip



This command creates a new archive file, Draft.zip, by compressing two files, Draftdoc.docx and diagram2.vsd, specified by the LiteralPath parameter. The compression level
specified for this operation is Optimal.




Example 2: Create a new archive with wildcard characters

PS C:\>Compress-Archive –Path C:\Reference\* -CompressionLevel Fastest –DestinationPath C:\Archives\Draft



This command creates a new archive file, Draft.zip, in the C:\Archives folder. Note that though the file name extension .zip was not added to the value of the
DestinationPath parameter, Windows PowerShell appends this to the specified archive file name automatically. The new archive file contains every file in the C:\Reference
folder, because a wildcard character was used in place of specific file names in the Path parameter. The specified compression level is Fastest, which might result in a
larger output file, but compresses a large number of files faster.




Example 3: Update an existing archive file

PS C:\>Compress-Archive –Path C:\Reference\* -Update –DestinationPath C:\Archives\Draft.Zip



This command updates an existing archive file, Draft.Zip, in the C:\Archives folder. The command is run to update Draft.Zip with newer versions of existing files that came
from the C:\Reference folder, and also to add new files that have been added to C:\Reference since Draft.Zip was initially created.




Example 4: Create an archive from an entire folder

PS C:\>Compress-Archive –Path C:\Reference –DestinationPath C:\Archives\Draft



This command creates an archive from an entire folder, C:\Reference. Note that though the file name extension .zip was not added to the value of the DestinationPath
parameter, Windows PowerShell appends this to the specified archive file name automatically.