param ( [Parameter(Mandatory=$true)] [string]$Url ) $ProgressPreference = 'SilentlyContinue' $FileName = Split-Path $Url -Leaf $DestDir = $FileName -replace '\.zip$', '' if (Test-Path $DestDir) { try { Remove-Item -Path $DestDir -Recurse -Force -ErrorAction Stop } catch { Write-Output "Deletion failed" exit } } try { Invoke-WebRequest -Uri $Url -OutFile $FileName -ErrorAction Stop Expand-Archive -Path $FileName -DestinationPath $DestDir -Force -ErrorAction Stop Remove-Item $FileName -ErrorAction Stop $true } catch { $false }