Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Created January 1, 2015 17:55
Show Gist options
  • Save trodemaster/9cd525139743751c3ee7 to your computer and use it in GitHub Desktop.
Save trodemaster/9cd525139743751c3ee7 to your computer and use it in GitHub Desktop.
Powershell function for unzipping files
function punzip( $zipfile, $outdir ) {
If(-not(Test-Path -path $zipfile)){return "zipfile " +$zipfile + " not found!"}
If(-not(Test-Path -path $outdir)){return "output dir " + $outdir + " not found!"}
$shell = new-object -com shell.application
$zip = $shell.NameSpace($zipfile)
foreach($item in $zip.items())
{
$shell.Namespace($outdir).copyhere($item)
}
}
# usage
# paramater 1 is path to zip file
# parameter 2 is directory to extract the archive
punzip ("c:\windows\temp\archive.zip") ("C:\windows\temp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment