33 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
| [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&msi_required=true")
 | |
| $AgentInstallFile = 'cybercnsagent.msi'
 | |
| $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 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 '$ArchivePath'"
 | |
| Remove-Item -Path $AgentInstallPath -Force |