If you follow my blog you’ve probably seen the trend of my install scripts being transformed into evergreen scripts crawling vendors website for executables.
You see, at every new version of my Automation Framework I manually updated all download links in tons of install wrappers. This is very time consuming and not to mention that they’re outdated in just a couple of weeks.
Now that the the growing popular Base Image Script Framework (BIS-F) is available on Github, it was time for me to create an Evergreen script. Here you go, have fun.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# Get latest version and download latest BIS-F release via GitHub API # URL Format : https://github.com/EUCweb/BIS-F/releases/download/6.1.2/setup-BIS-F-6.1.2_build01.109.exe # GitHub API to query repository $repo = "EUCweb/BIS-F" $releases = "https://api.github.com/repos/$repo/releases/latest" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $r = Invoke-WebRequest -Uri $releases -UseBasicParsing $latestRelease = ($r.Content | ConvertFrom-Json | Where-Object { $_.prerelease -eq $False })[0] $latestVersion = $latestRelease.tag_name # Array of releases and downloaded $releases = $latestRelease.assets | Where-Object { $_.name -like "setup-BIS-F*" } | ` Select-Object name, browser_download_url # PowerShell Wrapper for MDT, Standalone and Chocolatey Installation - (C)2015 xenappblog.com # Example 1: Start-Process "XenDesktopServerSetup.exe" -ArgumentList $unattendedArgs -Wait -Passthru # Example 2 Powershell: Start-Process powershell.exe -ExecutionPolicy bypass -file $Destination # Example 3 EXE (Always use ' '): # $UnattendedArgs='/qn' # (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode # Example 4 MSI (Always use " "): # $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp" # (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode # PowerShell Wrapper for MDT, Standalone and Chocolatey Installation - (C)2015 xenappblog.com # Example 1: Start-Process "XenDesktopServerSetup.exe" -ArgumentList $unattendedArgs -Wait -Passthru # Example 2 Powershell: Start-Process powershell.exe -ExecutionPolicy bypass -file $Destination # Example 3 EXE (Always use ' '): # $UnattendedArgs='/qn' # (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode # Example 4 MSI (Always use " "): # $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp" # (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode Clear-Host Write-Verbose "Setting Arguments" -Verbose $StartDTM = (Get-Date) $Vendor = "Misc" $Product = "BISF" $PackageName = "setup-BIS-F" $Version = $Version = $latestVersion.Trim(".windows.1 , v") $InstallerType = "exe" $Source = "$PackageName" + "." + "$InstallerType" $SourceXML = "$PackageName" + "." + "zip" $SourceCTX = "CitrixOptimizer.zip" $LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log" $LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log" $Destination = "${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" $UnattendedArgs = "/VERYSILENT /log:$LogApp /norestart /noicons" $url = $releases.browser_download_url | Select-Object -first 1 $xml = "https://eucweb.com/download/765/" $ctx = "http://xenapptraining.s3.amazonaws.com/Hydration/CitrixOptimizer.zip" $ProgressPreference = 'SilentlyContinue' Start-Transcript $LogPS if( -Not (Test-Path -Path $Version ) ) { New-Item -ItemType directory -Path $Version | Out-Null } CD $Version Write-Verbose "Downloading $Vendor $Product $Version" -Verbose If (!(Test-Path -Path $Source)) { Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $Source Write-Verbose "Downloading $Vendor $Product Reference Configuration" -Verbose Invoke-WebRequest -Uri $xml -OutFile $SourceXML Expand-Archive -Path $SourceXML -DestinationPath .\ Write-Verbose "Downloading Citrix Optimizer" -Verbose Invoke-WebRequest -Uri $ctx -OutFile $SourceCTX Expand-Archive -Path $SourceCTX -DestinationPath .\CitrixOptimizer } Else { Write-Verbose "File exists. Skipping Download." -Verbose } Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode Write-Verbose "Customization" -Verbose New-Item -ItemType directory -Path "C:\Program Files (x86)\Citrix Optimizer\" | Out-Null Copy-Item -Path .\CitrixOptimizer\* -Destination "C:\Program Files (x86)\Citrix Optimizer\" -Recurse -Force Copy-item -Path .\*.xml -Destination "C:\Program Files (x86)\Base Image Script Framework (BIS-F)" -Recurse -Force Write-Verbose "Stop logging" -Verbose $EndDTM = (Get-Date) Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose Stop-Transcript |