56 lines
1.9 KiB
PowerShell
56 lines
1.9 KiB
PowerShell
## Path to the MSI installer
|
|
$MSIURL = 'https://lfupdate.s3.amazonaws.com/clients/outlook/admin_msi/LiquidFiles_Admin_2.0.132.msi'
|
|
|
|
Install-PSAteraModule
|
|
Import-Module -Name PSAtera
|
|
|
|
## Get LF host URL from Atera
|
|
LogMsg "Getting LiquidFiles host URL from Atera API"
|
|
Try {
|
|
Set-AteraAPIKey -APIKey $AteraAPIKey
|
|
$AteraAgent = Get-AteraAgent
|
|
$LFHost = $(Get-AteraCustomValue -ObjectType Customer -ObjectId $AteraAgent.CustomerID -FieldName 'LiquidFiles Host URL').ValueAsString
|
|
}
|
|
Catch { LogErr $_.Exception.Message }
|
|
|
|
## Set installer args
|
|
If (-not [string]::IsNullOrEmpty($LFHost) ) {
|
|
LogMsg "LiquidFiles target server: ${LFHost}"
|
|
$INSTALLER_ARGS = "REGKEYSCRIPT=""BaseUrl=${LFHost};"""
|
|
}
|
|
Else { $INSTALLER_ARGS = '' }
|
|
|
|
## Stop any running LiquidFilesWindowsAgent process
|
|
$RunningProcess = Get-Process -Name "LiquidFilesWindowsAgent"
|
|
If ($RunningProcess) {
|
|
LogMsg "Stopping the LiquidFiles agent"
|
|
$RunningProcess | Stop-Process -Force
|
|
}
|
|
|
|
## Run the installer
|
|
$INSTALLER = Download-File -URL $MSIURL
|
|
LogMsg "Installing Liquid Files Outlook Agent from ""${INSTALLER}"""
|
|
Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart ${INSTALLER_ARGS}" -Wait -ErrorAction Stop }
|
|
Catch { LogErr $_.Exception.Message }
|
|
|
|
## Delete installer
|
|
Try {
|
|
LogMsg "Deleting downloaded installation package"
|
|
Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue
|
|
}
|
|
Catch { LogErr $_.Exception.Message }
|
|
|
|
## Start the agent
|
|
$PathToAgentExe64 = "${Env:ProgramFiles(x86)}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe"
|
|
$PathToAgentExe32 = "${Env:ProgramFiles}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe"
|
|
If ( Test-Path $PathToAgentExe64 ) {
|
|
$PathToAgentExe = $PathToAgentExe64
|
|
} ElseIf ( Test-Path $PathToAgentExe32 ) {
|
|
$PathToAgentExe = $PathToAgentExe32
|
|
}
|
|
If ($PathToAgentExe) {
|
|
LogMsg "Starting LiquidFiles agent"
|
|
Try { Start-Process $PathToAgentExe }
|
|
Catch { LogErr $_.Exception.Message }
|
|
}
|