ZIP and UnZIP/extract large Files

Problem: Need to deploy 11gb package via SCCM. So I compressed almost 11gb package into a ZIP file using windows native GUI method(Select all files --> Right click --> Send to Compressed ZIP folder.). Now I placed that ZIP file into our PSADT Files folder.

Question: How do I UnZIP/extract that huge ZIP file using PSADT script?

Tried methods:

  1. Expand-Archive - Did not work
  2. Adding this function in to “AppDeployToolkitExtensions.ps1” in the “AppDeployToolkitfolder”
    Function Expand-ZIPFile($file, $destination)
    {
    $shell = New-Object -com shell.application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    {
    $shell.Namespace($destination).copyhere($item,20)
    }
    }

Hi,

What error message did you get with Expand-Archive?
Have you considered using 7-Zip? You can usually get better compression and there is a standalone executable that you can bundle with the package if it’s not installed on the client computer.

Jonathan

I could be mis-remembering but I believe Expand-Archive wasn’t included with PoSH 2.0, so if you’re still running older versions of Windows that could explain the failure.

Our work-around was this function:

Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param ([string]$zipfile,
[string]$outpath)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)

}

Call unzip with Name.zip and destination folder arguments.

The suggestion to try 7-Zip does sound more attractive than this though. Could be an interesting test to see what’s quicker.

Thank you guys for the reply.

I tried the Native PowerShell(>2.0) command Expand-Archive and it worked fine for me now. The reason it did not work before was I created the at ZIP file in a Windows Server 2012 by GUI method(Select all files --> Right click --> Send to Compressed ZIP folder).

Now I deleted the Old ZIP file and re-zipped those same files in a Windows 10 machine using the same GUI method(Select all files --> Right click --> Send to Compressed ZIP folder.). Then used Expand-Archive cmdlet to extract the files and it just worked without any issues.

I finally realized the method we use to ZIP files may matter it seems. I also verified the 7-ZIP method which worked with out any issues but when I am unzipping the files in a client machine where 7-ZIP is not installed I need to copy the 7zip.exe and run the commands

That’s great that you’ve got it working. It is strange that ZIP files created on Windows 10 and Server 2012 are different. I suspect like most people, I’ve never tried to do it on a server.

I’ve found 7 Zip gives a lot better compression, especially if you select 7z as the archive format and Ultra as the compression level. Less space used on the Distribution Point and client machines, which is always good!

Jonathan

1 Like