Sample code for 30+ languages & platforms
PowerShell

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

$bz2 = New-Object Chilkat.Bz2

# Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
$success = $bz2.CompressFile("qa_data/hamlet.xml","qa_output/hamlet.bz2")
if ($success -ne $true) {
    $($bz2.LastErrorText)
    exit
}

$("Success.")