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 {
<#
.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 "$Var_SourceFiles\p24447599_122120_Generic.zip" "$env:systemdrive\PATCH_JDEV12"
.NOTES
.LINK
#>
[CmdletBinding()]
Param (
## Specify process names separated by commas. Optionally specify a process description with an equals symbol, e.g. "winword=Microsoft Office Word"
[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 = "$(Resolve-Error)"
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
Exit-Script -ExitCode $mainExitCode
Set-StrictMode -Version Latest
}
}
End {Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer}
}</code>