function Expand-ZipWithLog {
[CmdletBinding()]
param(
[Parameter(Mandatory)] [string]$ZipPath,
[Parameter(Mandatory)] [string]$Destination,
[Parameter(Mandatory)] [string]$LogFile
)
try {
if (-not (Test-Path -LiteralPath $Destination)) {
New-Item -Path $Destination -ItemType Directory -Force | Out-Null
}
Expand-Archive -LiteralPath $ZipPath -DestinationPath $Destination -Force
Write-Log -Path $LogFile -Component 'Archive' -Type Info -Message "Archiv entpackt: $ZipPath -> $Destination"
}
catch {
Write-Log -Path $LogFile -Component 'Archive' -Type Error -Message "Archiv konnte nicht entpackt werden: $ZipPath. $($_.Exception.Message)"
throw
}
}