You are not logged in.
Is there powershell itself method to unzip files?
I found this below in the web.
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
}
I tried this, but it doesn't work.
Do you have any other way to unzip? or correct this code?
Offline
This part
foreach($file in $a)
{
Write-Host "Processing - $file" UnZipMe –zipfilename
$file.FullName -destination $file.DirectoryName
}
looks like it should be
foreach($file in $a)
{
Write-Host "Processing - $file"
UnZipMe –zipfilename $file.FullName -destination $file.DirectoryName
}
Also the code looks to me like it's dependent on the Windows Explorer support for zipFolders, which you may have turned off
Unregister (disable) XP Zip folders
REGSVR32 /u C:\Windows\System32\zipfldr.dll
Register (enable) XP Zip folders
REGSVR32 zipfldr.dll
Offline