workaround for long url
This commit is contained in:
@@ -21,8 +21,30 @@ If ( $(Get-MBSAgent -ErrorAction SilentlyContinue) ) {
|
||||
Return
|
||||
}
|
||||
|
||||
# Download the installer
|
||||
$Installer = Download-File -URL $URL
|
||||
#
|
||||
# The URL is now too long to pass as a variable to other functions and cmdlets, so this is a workaround to download the file
|
||||
#
|
||||
|
||||
# Make sure the URL is valid
|
||||
$StatusCode = [System.Net.WebRequest]::Create($URL).GetResponse().StatusCode
|
||||
If ( !(($StatusCode -ge 200) -and ($StatusCode -lt 400)) ) { Write-Output "URL cannot be reached (status code ${StatusCode}): ${URL}" ; Return }
|
||||
|
||||
# Make a local file to download to
|
||||
$Installer = '{0}EmberkomCloudBackup.exe' -f (Get-TempPath)
|
||||
|
||||
# Delete previous local file if it exists
|
||||
If ( Test-Path $File ) { Write-Output "Deleting previously downloaded file: ${File}" ; Remove-Item $File -Force -ErrorAction SilentlyContinue}
|
||||
|
||||
# Download the file
|
||||
Try { (New-Object System.Net.WebClient).DownloadFile($URL,$File) }
|
||||
Catch { Write-Error $_.Exception.Message ; Remove-Item $File -Force -ErrorAction SilentlyContinue }
|
||||
|
||||
# Make sure the file exists
|
||||
If ( !(Test-Path $File) ) { Write-Output "There was a problem downloading the file, this script will not continue" ; Return }
|
||||
|
||||
#
|
||||
# End the workaround
|
||||
#
|
||||
|
||||
# Install the agent
|
||||
Write-Output "Installing Emberkom Cloud Backup agent"
|
||||
@@ -48,6 +70,9 @@ Try {
|
||||
}
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
|
||||
# Delete $Installer
|
||||
If ( Test-Path $Installer ) { Write-Output "Deleting downloaded file: ${Installer}" ; Remove-Item $Installer -Force -ErrorAction SilentlyContinue }
|
||||
|
||||
# Delete the desktop icon
|
||||
If ( Test-Path "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK" ) { Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK" -Force -ErrorAction SilentlyContinue }
|
||||
If ( Test-Path "${Env:PUBLIC}\Desktop\Emberkom Cloud Backup.LNK" ) { Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Cloud Backup.LNK" -Force -ErrorAction SilentlyContinue }
|
||||
|
||||
Reference in New Issue
Block a user