function unzip([string] $path, [string]$zipFile) { if (!(test-path -path $zipFile)) { return; } $shell=new-object -com shell.application; $ZipFolder = $shell.namespace("$ZipFile"); # make sure the path is created if (!(test-path -path $path)) { mkdir $path | out-null; } else { foreach ($srcItem in $ZipFolder.Items()) { $dstItemPath = join-path -path $path -childpath $srcItem.path; $exists = Test-Path -Path $dstItemPath; if ($exists) # If the item doesn't exist in the desination directory... { Remove-Item -Path $dstItemPath -Recurse; } } } $destinationFolder=$shell.namespace("$path"); $destinationFolder.Copyhere($ZipFolder.items()); } function zip([string] $path, [string] $zipFile) { # make sure the path is created if (!(test-path -path $path)) { return; } # make sure no zip file does NOT exists, because the UI need human interaction if (test-path -path $zipFile) { remove-item -path $zipFile -force; } set-content $zipFile ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)); $src=get-item $path; $shell=new-object -com shell.application; $dst = $shell.namespace("$zipFile"); foreach ($item in $src) { $dst.Copyhere($item.fullname); } }