Zipfile - PowerShell


The ZipFile command compresses and archives files and directories into a single ZIP archive, offering reliable file compression, secure data storage, and convenient file transfer. It plays a vital role in managing and organizing large volumes of data.


   [-Path] <string>
   [-Destination] <string>
   [-Recurse] [-RecurseDepth <int>]
   [-ExcludePattern <string>]
   [-IncludePattern <string>]
   [-CompressLevel <int>]
   [-ThrottleLimit <int>]


  • -Destination: Specifies the output path and filename for the ZIP archive.
  • -Force: Overwrites an existing ZIP archive with the same name without prompting.
  • -PassThru: Returns the compressed file as a FileSystemInfo object.
  • -Recurse: Compresses subdirectories and their contents.
  • -RecurseDepth: Specifies the maximum level of subdirectories to compress.
  • -ExcludePattern: Excludes files and directories matching the specified pattern. Supports wildcards (* and ?).
  • -IncludePattern: Includes only files and directories matching the specified pattern. Supports wildcards (* and ?).
  • -Checksum: Calculates and adds a checksum to each file in the ZIP archive.
  • -CompressLevel: Sets the compression level from 0 (no compression) to 9 (maximum compression).
  • -ThrottleLimit: Limits the number of concurrent operations.


Basic Usage

ZipFile -Path ./files -Destination ./

Compressing with Patterns and Checksums

ZipFile -Path ./directory -Destination ./ -ExcludePattern "*.txt" -IncludePattern "*.pdf" -Checksum

Compression with Recursion

ZipFile -Path ./root -Destination ./ -Recurse -RecurseDepth 2

Custom Compression Level

ZipFile -Path ./files -Destination ./ -CompressLevel 9

Common Issues

  • Ensure the destination path does not contain invalid characters or special symbols.
  • Check that you have sufficient permissions to modify the destination path.
  • Exclude large, unnecessary files to reduce archive size and improve performance.
  • Use patterns carefully to avoid excluding critical files.


  • The ZipFile command can be combined with Copy-Item to backup and archive data.
  • Utilize Get-Item and Where-Object to filter specific items before archiving.
  • Compress-Archive is an alternative command that compresses files into various archive formats, including ZIP.