Created
January 1, 2015 17:55
-
-
Save trodemaster/9cd525139743751c3ee7 to your computer and use it in GitHub Desktop.
Powershell function for unzipping files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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