Zip missing in toolkit

//Zip missing in toolkit
Zip missing in toolkit 2017-04-11T17:15:43+00:00

The Toolkit Forums Toolkit Extensions Zip missing in toolkit

  • Author
    Posts
  • Francois
    Participant
    Post count: 101
    #2082 |

    Hi,

    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 {
    &lt;#	
    	.SYNOPSIS
    		Permet de decompresser des fichiers ZIP
    	.DESCRIPTION
    		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.
    	.PARAMETER
            $zipfile pour le chemin complet et le fichier zip
            $outpath pour le repertoire de destination
    	.EXAMPLE
           Expand-ZIP &quot;$Var_SourceFiles\p24447599_122120_Generic.zip&quot; &quot;$env:systemdrive\PATCH_JDEV12&quot;
    	.NOTES
    	.LINK	
    
    #&gt;
    	[CmdletBinding()]
    	Param (
    		## Specify process names separated by commas. Optionally specify a process description with an equals symbol, e.g. &quot;winword=Microsoft Office Word&quot;
    		[Parameter(Mandatory=$true)]
    		[ValidateNotNullorEmpty()]
    		[string]$Str_zipfile,
            [Parameter(Mandatory=$true)]
    		[ValidateNotNullorEmpty()]
    		[string]$Str_outpath
    	)
    	
    	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}
    }</code>

You must be logged in to reply to this topic.