[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $PackagesPath = 'C:\Packages' $TenantId = '' $CompanyId = '' $UserSecret = '' $AgentInstallUrl = (Invoke-RestMethod -Method "Get" -URI "https://configuration.myconnectsecure.com/api/v4/configuration/agentlink?ostype=windows") $AgentInstallFile = 'cybercnsagent.exe' $AgentInstallPath = Join-Path -Path $PackagesPath -ChildPath $AgentInstallFile # Prep # Create the $PackagesPath directory if it doesn't already exist if (-not (Test-Path -PathType Container $PackagesPath)) { New-Item -ItemType Directory -Path $PackagesPath | Out-Null } # Download Write-Host "Downloading agent installer..." # Use Legacy WebClient for compatibility (New-Object Net.WebClient).DownloadFile($AgentInstallUrl, $AgentInstallPath) # Install Write-Host "Starting installation..." Start-Process -FilePath $AgentInstallPath -ArgumentList "-c $($CompanyId) -e $TenantId -j $UserSecret -i" -Wait #Start-Process msiexec -ArgumentList "/i `"$AgentInstallPath`" /q WRAPPED_ARGUMENTS=`"-c $CompanyId -e $TenantId -j $UserSecret -i`" /lv `"$($AgentInstallPath).log`"" -Wait #Write-Host "Log saved at $($AgentInstallPath).log" # Clean up Write-Host "Removing package download from '$AgentInstallPath'" Remove-Item -Path $AgentInstallPath -Force