Skip to content

Instantly share code, notes, and snippets.

@thoemmi
Created May 6, 2012 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoemmi/2623371 to your computer and use it in GitHub Desktop.
Save thoemmi/2623371 to your computer and use it in GitHub Desktop.
Expand-ZipFile
function Expand-ZipFile {
param {
$zipPath,
$destination,
[switch] $quiet
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipPath)
$destinationFolder = $shellApplication.NameSpace($destination)
# CopyHere vOptions Flag # 4 - Do not display a progress dialog box.
# 16 - Respond with "Yes to All" for any dialog box that is displayed.
#$destinationFolder.CopyHere($zipPackage.Items(),20)
$total = $zipPackage.Items().Count
$progress = 1;
foreach ($zipFile in $zipPackage.Items()) {
if (!$quiet) {
Write-Progress "Extracting $zipPath" "Extracting $($zipFile.Name)" -id 0 -percentComplete (($progress/$total)*100)
}
$destinationFolder.CopyHere($zipFile,20)
$progress++
}
if (!$quiet) {
Write-Progress "Extracted $zipPath" "Extracted $total items" -id 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment