Unzip several files with PowerShell

Tags: powershell

Here is a function I used to unzip several files using PowerShell. 

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:inetpubiislogs3.comwwwlogs -Filter *.zip

foreach($file in $a)
{
    Write-Host “Processing – $file” UnZipMe –zipfilename
    $file.FullName -destination $file.DirectoryName
}

1 Comment

Add a Comment