2026-01-02 14:21:40 -05:00

56 lines
1.6 KiB
PowerShell

[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String]
$Token
)
<#
.SYNOPSIS
Install ConnectWise RMM
.DESCRIPTION
Download and install the ConnectWise RMM agent with the given token
.PARAMETER Token
Agent install token (required)
.EXAMPLE
.\Install-CWRMM.ps1 -Token '7672b2ed-c04c-477c-9d34-341762cdaeee'
#>
begin {
$InstallerUrl = 'https://prod.setup.itsupport247.net/windows/BareboneAgent/32/ITSagent/MSI/setup'
$InstallerPath = Join-Path -Path $env:TEMP -ChildPath 'AsioAgentInstaller.msi'
}
process {
Write-Host "Installing ConnectWise RMM with token '$token'..."
# Download
try {
Write-Host "Downloading application..."
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
# Use Legacy WebClient for compatibility
(New-Object Net.WebClient).DownloadFile($InstallerUrl, $InstallerPath)
} catch {
throw "Failed downloading application. $_"
}
# Install
try {
Write-Host "Installing application..."
Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/i `"$InstallerPath`" TOKEN=$Token /qn /lv `"$($InstallerPath).log`"" -Wait
Write-Host "Log saved at '$($InstallerPath).log'"
# Get-Content "$($InstallerPath).log"
} catch {
throw "Failed installing application. $_"
}
}
# Clean up
end {
if (Test-Path $InstallerPath) {
Write-Host "Removing package download from '$InstallerPath'"
Remove-Item -Path $InstallerPath -Force
}
}