NOTE:
Powershell Script - Windows
To run on a local machine without RMM, you may have to bypass the machine’s execution policy with:
powershell.exe -noprofile -executionpolicy bypass -file '.\Timus Silent Install.ps1'
Windows:
<#
Timus Connect Windows Installation Script
***Always review to make sure you know what a script is doing.***
#>
# 1. Check if Timus Connect is already installed
$appName = 'Timus Connect'
$RegUninstallKey = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
$installedApplication = Get-ItemProperty -Path $RegUninstallKey | Where-Object { $_.DisplayName -like "*$appName*" }
if ($installedApplication) {
Write-Host "Timus Connect is already installed. Exiting script."
Exit 0
}
# 2. Check if this is a desktop or laptop
$systemType = "Unknown"
$BatteryStatus = (Get-WmiObject -Class Win32_Battery -EA SilentlyContinue).Status
if ($BatteryStatus) {
$systemType = "Laptop"
} else {
$systemType = "Desktop"
}
Write-Output "This device is a $systemType"
# 3. Create download directory if it doesn't exist
$dlFolder = "C:\temp\Timus Networks"
$dlDest = "$dlFolder\Timus-Connect.exe"
$dlUrl = "https://repo.timuscloud.com/connect/Timus-Connect.exe"
$tempFolderExists = Test-Path -Path "C:\Temp"
if (-not (Test-Path -Path $dlFolder)) {
Write-Output "Download directory does not exist. Creating directory..."
New-Item -ItemType Directory -Path $dlFolder -Force | Out-Null
} else {
Write-Output "Download directory exists. Continuing..."
}
# 4. Try to download the installer
$downloaded = $false
try {
Invoke-WebRequest -Uri $dlUrl -OutFile $dlDest -ErrorAction Stop
Write-Output "Download successful with Invoke-WebRequest."
$downloaded = $true
} catch {
Write-Output "Invoke-WebRequest failed. Trying WebClient..."
try {
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($dlUrl, $dlDest)
Write-Output "Download successful with WebClient."
$downloaded = $true
} catch {
Write-Output "WebClient failed. Trying Start-BitsTransfer..."
try {
Start-BitsTransfer -Source $dlUrl -Destination $dlDest
Write-Output "Download successful with BitsTransfer."
$downloaded = $true
} catch {
Write-Host "All download methods failed. Exiting script."
Exit 1
}
}
}
# 5. Install Timus Connect
if ($downloaded -and (Test-Path $dlDest)) {
try {
Start-Process -Wait -FilePath $dlDest -ArgumentList "/S" -ErrorAction Stop
Write-Host "Installation initiated successfully."
} catch {
Write-Host "Installation failed. Exiting."
Exit 1
}
}
# 6. Verify installation
$installedApplication = Get-ItemProperty -Path $RegUninstallKey | Where-Object { $_.DisplayName -like "*$appName*" }
if ($installedApplication) {
Write-Host "Application installed successfully."
} else {
Write-Host "Application installation failed or not detected."
Exit 1
}
# 7. Cleanup
if ($tempFolderExists) {
Write-Output "Cleaning up: removing $dlFolder only."
Remove-Item -Path $dlFolder -Recurse -Force -ErrorAction SilentlyContinue
} else {
Write-Output "Cleaning up: removing entire C:\Temp folder."
Remove-Item -Path "C:\Temp" -Recurse -Force -ErrorAction SilentlyContinue
}
Write-Output "Cleanup complete. Exiting."
Exit 0
1 comment
Brandon Fox
This script doesn't exit if it finds the app. It's missing the exit call. Please update
Please sign in to leave a comment.