Zip missing in toolkit


I had to package some ziped Java file. So to deploy them, I was believing using the toolkit to unzip those files. I was surprise to see PSADTK containing a way to create a zip but not to unzip a file.

So I wrote a way to unzip de file.

<code>Function Expand-ZIP {
		Permet de decompresser des fichiers ZIP
		Permet de decompresser des fichiers ZIP
        - Emplacement complet du fichier zippé source a déterminer et aussi le repertoire de destination
        - Le repertoire clible sera creer automatiquement si il est absent.
        $zipfile pour le chemin complet et le fichier zip
        $outpath pour le repertoire de destination
       Expand-ZIP &quot;$Var_SourceFiles\; &quot;$env:systemdrive\PATCH_JDEV12&quot;

	Param (
		## Specify process names separated by commas. Optionally specify a process description with an equals symbol, e.g. &quot;winword=Microsoft Office Word&quot;
	Begin {
		## Get the name of this function and write header
		[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
		Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
	Process {

        Try {

            Add-Type -AssemblyName System.IO.Compression.FileSystem
            [System.IO.Compression.ZipFile]::ExtractToDirectory($Str_zipfile, $Str_outpath)
        Catch {

            Set-StrictMode -off
				[int32]$mainExitCode = 1
				[string]$mainErrorMessage = &quot;$(Resolve-Error)&quot;
				Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
				Show-DialogBox -Text $mainErrorMessage -Icon &#039;Stop&#039;
				Exit-Script -ExitCode $mainExitCode
			Set-StrictMode -Version Latest

    End {Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer}
1 Like

I also preferr to have the source-files zipped. Makes it easier and faster to dowonload one file instead of a whole structure

Why not create a pull request on Github? :slight_smile:

That’s because System.IO.Compression.ZipFile was added in .NET Framework 4.5
The toolkit supports win7,8,8.1,10 which dont come with .NET Framework 4.5 by default so your function wouldn’t work on machines without this version.
The current zipfile command doesn’t use this class and is actually using an unreliable way to do this.
There is a way to unzip it in a similar way though so we can add that but i think we should use something better.