Some time ago I pulled together someone's post to come up with a function to zip files without using any third party tools. Looking back, it is very rough, and, could be revisited. Nonetheless, I've got a big project due in a couple of days and none of the unzipping snippets I have found work very well. Steve Schofield, of the IIS team, had this post, however, which works pretty well so far:
Unzip several files with PowerShell
The snippet, to save you the hop over, if you're in a hurry, looks like this:
function UnZipMe($zipfilename,$destination)
{
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$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)
}
$a = gci -Path C:\inetpub\iislogs3.com\wwwlogs -Filter *.zip
foreach($file in $a)
{
Write-Host "Processing - $file" UnZipMe –zipfilename
$file.FullName -destination $file.DirectoryName
}
0 comments:
Post a Comment