Compress Archive - PowerShell


Compress-Archive is a PowerShell command that creates ZIP archives. It provides a convenient and efficient way to compress files and folders, reducing their size for storage or transfer. This command is particularly useful when dealing with large datasets or when sharing files over networks or email.


Compress-Archive -Path <PathToFolder> -DestinationPath <ZippedFilePath> [-CompressionLevel <0-9>] [-Force]


  • Path (Required): Specifies the path to the folder or files to compress.
  • DestinationPath (Required): Specifies the destination path and filename for the compressed archive.
  • CompressionLevel (Optional): Sets the compression level from 0 (no compression) to 9 (maximum compression). Default is 5.
  • Force (Optional): Overwrites an existing archive file at the DestinationPath without prompting.


Simple Use:

Compress-Archive -Path "C:\Docs" -DestinationPath "C:\"

Setting Compression Level:

Compress-Archive -Path "C:\Photos" -DestinationPath "C:\" -CompressionLevel 8

Force Overwrite:

Compress-Archive -Path "C:\Projects" -DestinationPath "C:\" -Force

Common Issues

  • Insufficient Permissions: Ensure you have sufficient permissions to create files in the destination path.
  • Non-Existing Destination Path: Verify that the specified DestinationPath is a valid directory.
  • Unsupported File Formats: Compress-Archive supports regular files, but not special files like shortcuts or hard links.


Chaining Commands:

Get-ChildItem -Path "C:\Dir1" | Compress-Archive -DestinationPath "C:\"

Using with Variables:

$files = Get-ChildItem -Path "C:\Dir2"
Compress-Archive -Path $files -DestinationPath "C:\"