$zipUrl = "https://docs.itau.uni-weimar.de/attachments/15" $destFolder = "$env:APPDATA\Grasshopper\Libraries" $zipFilePath = "$env:TEMP\sample.zip" try { # Download the zip file $ProgressPreference = 'SilentlyContinue' Write-Host "Downloading zip file from $zipUrl..." Invoke-WebRequest -Uri $zipUrl -OutFile $zipFilePath # Create destination folder if it doesn't exist if (-not (Test-Path -Path $destFolder)) { New-Item -Path $destFolder -ItemType Directory -Force } # Delete all contents in the destination folder Write-Host "Clearing contents of $destFolder..." Remove-Item -Path "$destFolder\*" -Recurse -Force # Extract the zip file to the destination folder Write-Host "Extracting zip file to $destFolder..." Expand-Archive -Path $zipFilePath -DestinationPath $destFolder -Force # Delete the zip file Write-Host "Deleting zip file..." Remove-Item -Path $zipFilePath -Force Write-Host "Script completed successfully." } catch { Write-Host "An error occurred: $_" } finally { # Ensure zip file is deleted even if an error occurs if (Test-Path -Path $zipFilePath) { Remove-Item -Path $zipFilePath -Force } }