Remote installation of the CPM Agent

Remote installation of the CPM Agent

In order to remotely install the CPM Agent on a remote server, you can use its silent install feature.
Here is a sample Powershell script to be executed on the remote server:

$download_dir = "c:\cpm_agent"
$cpm_server_address = "12.345.67.89"

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

mkdir "$download_dir"
Set-Location "$download_dir"

$wc = New-Object System.Net.WebClient
$wc.DownloadFile("$cpm_url", "${download_dir}/CPMAgentService.msi")

$command_arguments = "/quiet /i CPMAgentService.msi SERVER_ADDRESS=${cpm_server_address}"

Start-Process "msiexec.exe" $command_arguments -NoNewWindow -Wait

If ($?) {
    "CPM Windows agent installed successfully"
    Set-Location "c:\"
    Remove-Item -Recurse $download_dir
    exit 0
} else {
    "There was a problem while installing CPM Windows agent. Check ${download_dir} location for installation file"
    exit 1

Please note that if an Agent of version prior to v2.0.0 is already installed on the remote server, it needs to be uninstalled first.