Quick Bytes: Unzipping ZIP file using Powershell
UNZIP.ps1
$zipfilename=”C:\myfolder\myzip.zip"; # Replace with source ZIP file
$destination=”C:\myfolder\unzipped"; # Replace with target folderif(test-path($zipfilename)) # Test if the zip file exists
{
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}else
{
echo "The source ZIP file does not exist";
}Published Tuesday, April 14, 2009 8:28 PM by ssehgal
The Deployment guy : Quick Bytes: Unzipping ZIP file using Powershell
6 comments:
Obviously in the world there tool which better than winzip,and to my mind this is next application-zip file check,it is better works with zip files and it resources wider as far as I can see than winzip,also it has free status as how as I remember,software permits to repair corrupted archives with *.zip extension,solve errors on example-CRC error and Cannot open file: it does not appear to be a valid archive,program for check repair zip file and check integrity of zip file uses several different algorithms for crc check fix zip file and data recovery, that is why, the process will take some time, according to CPU performance and file size,program will work under all supported versions of this operating system,will keep initial structure of your archive as well as original names of files and directories,check repair zip file can check why zip file is corrupted and work with password protected archives, but you should know this password.
One day I unpacked my zip files and unexpectedly the light switched off. My data were lost. I decided to use the Inet. For luck I stumbled across there - how do i work on my corrupt zip files. The software solved my proposition quite hands down and I didn't waste the money.
might be better to parameterize the script ?
param (
[Parameter(mandatory=$true)][string] $zipfilename, #source ZIP file
[Parameter(mandatory=$true)][string] $destination #target folder
)
if(test-path($zipfilename)) # Test if the zip file exists
{
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}
else
{
echo "The source ZIP file does not exist";
}
http://stackoverflow.com/questions/2359372/powershell-copyhere-if-it-already-exists-work-around
Post a Comment