Created
February 8, 2023 04:20
-
-
Save aaronparker/a0865c0da0893095fca8235e66e8887e to your computer and use it in GitHub Desktop.
Downloads and installs the latest version or a specific version of the Microsoft FSLogix Apps agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Modules Evergreen | |
<# | |
.SYNOPSIS | |
Installs the Microsoft FSLogix Apps agent | |
#> | |
[CmdletBinding()] | |
param ( | |
[System.String] $Path = "$Env:SystemDrive\Apps\Microsoft\FSLogix", | |
[System.String] $Version | |
) | |
#region Agent history - allow installing a specific version in the event of an issue | |
$Versions = @" | |
[ | |
{ | |
"Version": "2.9.8361.52326", | |
"Date": "12/13/2022", | |
"Channel": "Production", | |
"URI": "https://download.microsoft.com/download/0/a/4/0a4c3a18-f6c8-4bcd-91fc-97ce845e2d3e/FSLogix_Apps_2.9.8361.52326.zip" | |
}, | |
{ | |
"Version": "2.9.8228.50276", | |
"Date": "07/21/2022", | |
"Channel": "Production", | |
"URI": "https://download.microsoft.com/download/d/1/9/d190de51-f1c1-4581-9007-24e5a812d6e9/FSLogix_Apps_2.9.8228.50276.zip" | |
}, | |
{ | |
"Version": "2.9.8171.14983", | |
"Date": "05/24/2022", | |
"Channel": "Production", | |
"URI": "https://download.microsoft.com/download/e/a/1/ea1bcf0a-e66d-48d2-ac9f-e385e5a7456e/FSLogix_Apps_2.9.8171.14983.zip" | |
}, | |
{ | |
"Version": "2.9.8111.53415", | |
"Date": "03/25/2022", | |
"Channel": "Production", | |
"URI": "https://download.microsoft.com/download/9/2/5/9257adcf-abdf-4ab3-b37f-416d70682315/FSLogix_Apps_2.9.8111.53415.zip" | |
} | |
] | |
"@ | |
#endregion | |
#region Script logic | |
New-Item -Path $Path -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null | |
New-Item -Path "$Env:ProgramData\Evergreen\Logs" -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null | |
try { | |
# Download and unpack | |
Import-Module -Name "Evergreen" -Force | |
if ($null -eq $Version) { | |
# Use Evergreen to find the latest version | |
$App = Invoke-EvergreenApp -Name "MicrosoftFSLogixApps" | Where-Object { $_.Channel -eq "Production" } | Select-Object -First 1 | |
} | |
else { | |
# Use the JSON in this script to select a specific version | |
$App = $Versions | ConvertFrom-Json | Where-Object { $_.Version -eq $Version } | |
} | |
$OutFile = Save-EvergreenApp -InputObject $App -CustomPath $Path -WarningAction "SilentlyContinue" | |
Expand-Archive -Path $OutFile.FullName -DestinationPath $Path -Force | |
} | |
catch { | |
throw $_.Exception.Message | |
} | |
# Install | |
Write-Information -MessageData ":: Install Microsoft FSLogix agent" -InformationAction "Continue" | |
foreach ($file in "FSLogixAppsSetup.exe", "FSLogixAppsRuleEditorSetup.exe") { | |
$Installers = Get-ChildItem -Path $Path -Recurse -Include $file | Where-Object { $_.Directory -match "x64" } | |
foreach ($Installer in $Installers) { | |
try { | |
$LogFile = "$Env:ProgramData\Evergreen\Logs\$($Installer.Name)$($App.Version).log" -replace " ", "" | |
$params = @{ | |
FilePath = $Installer.FullName | |
ArgumentList = "/install /quiet /norestart /log $LogFile" | |
NoNewWindow = $true | |
Wait = $true | |
PassThru = $true | |
ErrorAction = "Continue" | |
} | |
$result = Start-Process @params | |
Write-Information -MessageData ":: Install exit code: $($result.ExitCode)" -InformationAction "Continue" | |
} | |
catch { | |
throw $_.Exception.Message | |
} | |
} | |
} | |
Start-Sleep -Seconds 5 | |
$Shortcuts = @("$Env:ProgramData\Microsoft\Windows\Start Menu\FSLogix\FSLogix Apps Online Help.lnk") | |
Remove-Item -Path $Shortcuts -Force -ErrorAction "Ignore" | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment