Skip to content

Commit dc54049

Browse files
author
Jonathan Pitre
committed
Fix download error
Add preference file
1 parent 66c55e0 commit dc54049

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

FileZilla/Install.ps1

+32-34
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Get-ChildItem -Recurse *.ps*1 | Unblock-File
1616
$env:SEE_MASK_NOZONECHECKS = 1
1717
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
1818
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
19-
$Modules = @("PSADT", "Evergreen") # Modules list
19+
$Modules = @("PSADT", "Nevergreen") # Modules list
2020

2121
Function Get-ScriptPath
2222
{
@@ -177,24 +177,34 @@ Foreach ($Module in $Modules)
177177
#-----------------------------------------------------------[Functions]------------------------------------------------------------
178178

179179
#region Functions
180+
180181
#endregion
181182

182183
#----------------------------------------------------------[Declarations]----------------------------------------------------------
183184

185+
#region Declarations
186+
184187
$appName = "FileZilla"
185188
$appProcesses = @("filezilla", "fzputtygen", "fzsftp")
186189
$appInstallParameters = "/S /user=all"
190+
# Set browser agent, powershell is blocked - https://twitter.com/xenappblog/status/1659325235127042050
191+
$userAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
187192
$Evergreen = Get-EvergreenApp -Name $appName
188-
$appVersion = $Evergreen.Version
189193
$appURL = $Evergreen.URI
194+
$appVersion = $Evergreen.Version
190195
$appSetup = Split-Path -Path $appURL -Leaf
191-
$appLanguage = "fr"
196+
$appConfigURL = "https://raw.githubusercontent.com/JonathanPitre/Apps/master/FileZilla/fzdefaults.xml"
197+
$appConfig = Split-Path -Path $appConfigURL -Leaf
192198
$appDestination = "$env:ProgramFiles\FileZilla FTP Client"
193-
[boolean]$IsAppInstalled = [boolean](Get-InstalledApplication -Name "$appName.*" -RegEx)
194-
$appInstalledVersion = ((Get-InstalledApplication -Name "$appName.*" -RegEx).DisplayVersion))
199+
[boolean]$isAppInstalled = [boolean](Get-InstalledApplication -Name "$appName.*" -RegEx)
200+
$appInstalledVersion = ((Get-InstalledApplication -Name "$appName.*" -RegEx).DisplayVersion)
201+
202+
#endregion
195203

196204
#-----------------------------------------------------------[Execution]------------------------------------------------------------
197205

206+
#region Execution
207+
198208
If ([version]$appVersion -gt [version]$appInstalledVersion)
199209
{
200210
Set-Location -Path $appScriptPath
@@ -205,7 +215,18 @@ If ([version]$appVersion -gt [version]$appInstalledVersion)
205215
If (-Not(Test-Path -Path $appScriptPath\$appVersion\$appSetup))
206216
{
207217
Write-Log -Message "Downloading $appName $appVersion..." -Severity 1 -LogType CMTrace -WriteHost $True
208-
Invoke-WebRequest -UseBasicParsing -Uri $appURL -OutFile $appSetup
218+
Invoke-WebRequest -UseBasicParsing -Uri $appURL -OutFile $appSetup -UserAgent $userAgent
219+
}
220+
Else
221+
{
222+
Write-Log -Message "File(s) already exists, download was skipped." -Severity 1 -LogType CMTrace -WriteHost $True
223+
}
224+
225+
# Download required config file
226+
If (-Not(Test-Path -Path "$appScriptPath\$appConfig"))
227+
{
228+
Write-Log -Message "Downloading $appName Config.." -Severity 1 -LogType CMTrace -WriteHost $True
229+
Invoke-WebRequest -UseBasicParsing -Uri $appConfigURL -OutFile "$appScriptPath\$appConfig" -UserAgent $userAgent
209230
}
210231
Else
211232
{
@@ -227,33 +248,8 @@ If ([version]$appVersion -gt [version]$appInstalledVersion)
227248

228249
Write-Log -Message "Applying customizations..." -Severity 1 -LogType CMTrace -WriteHost $True
229250

230-
<#
231-
# Configure application shortcut
232-
Copy-File -Path "$envCommonStartMenuPrograms\$appName\$appName File Manager.lnk" -Destination "$envCommonStartMenuPrograms" -ContinueFileCopyOnError $True
233-
Remove-Folder -Path "$envCommonStartMenuPrograms\$appName" -ContinueOnError $True
234-
235-
# Load the Default User registry hive
236-
Write-Log -Message "Loading the Default User registry hive..." -Severity 1 -LogType CMTrace -WriteHost $True
237-
Start-Sleep -Seconds 5
238-
Execute-Process -Path "$envWinDir\System32\reg.exe" -Parameters "LOAD HKLM\DefaultUser $envSystemDrive\Users\Default\NTUSER.DAT" -WindowStyle Hidden
239-
240-
# Configure application display language
241-
If ($appLanguage -ne "en")
242-
{
243-
Set-RegistryKey -Key "HKLM:\DefaultUser\Software\7-Zip" -Name "Lang" -Type String -Value $appLanguage
244-
}
245-
Else
246-
{
247-
Set-RegistryKey -Key "HKLM:\DefaultUser\Software\7-Zip" -Name "Lang" -Type String -Value "-"
248-
}
249-
250-
# Cleanup (to prevent access denied issue unloading the registry hive)
251-
[GC]::Collect()
252-
Start-Sleep -Seconds 5
253-
254-
# Unload the Default User registry hive
255-
Execute-Process -Path "$envWinDir\System32\reg.exe" -Parameters "UNLOAD HKLM\DefaultUser" -WindowStyle Hidden
256-
#>
251+
# Copy preferences file
252+
Copy-File -Path "$appScriptPath\$appConfig" -Destination $appDestination
257253

258254
# Go back to the parent folder
259255
Set-Location ..
@@ -264,4 +260,6 @@ If ([version]$appVersion -gt [version]$appInstalledVersion)
264260
Else
265261
{
266262
Write-Log -Message "$appName $appInstalledVersion is already installed." -Severity 1 -LogType CMTrace -WriteHost $True
267-
}
263+
}
264+
265+
#endregion

0 commit comments

Comments
 (0)