# - Upload the Avantra Agent installer as a package to the Agent Update rpository# - Adapt these variable according to your needs# - Modify the execution policy to allow running powershell scripts[string]$user='<DOMAIN\user>'# Access to the remote system[string]$target='<target-host>'# The remote system[string]$masterhost='<avantra-server>'# The FQDN of the Avantra Sever[string]$agentversion='20.5.0'# The agent version (uploaded to the repository)[string]$javapath='C:\Program Files\Java'# Adapt this to the latest version: Make your choice on https://adoptopenjdk.net/releases.html, right-click to get link[uri]$javaurl='https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u252-b09.1/OpenJDK8U-jre_x64_windows_hotspot_8u252b09.msi'# There should be no need to change anything below this line[uri]$agenturl='http://'+$masterhost+':9050/AgentUpdate/agent-'+$agentversion+'-setup.exe'# Self-elevate the script if requiredif(-Not([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')){if([int](Get-CimInstance-ClassWin32_OperatingSystem|Select-Object-ExpandPropertyBuildNumber)-ge6000){$CommandLine="-File `""+$MyInvocation.MyCommand.Path+"`" "+$MyInvocation.UnboundArgumentsStart-Process-FilePathPowerShell.exe-VerbRunas-ArgumentList$CommandLineExit}}$session=New-PSSession-ComputerName$target-Credential$userInvoke-Command-Session$session-ScriptBlock{param($javaurl,$agenturl,$javapath)[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12Invoke-WebRequest`-Uri$javaurl`-OutFile'C:\Windows\Temp\java-installer.msi'Invoke-WebRequest`-Uri$agenturl`-OutFile'C:\Windows\Temp\agent-installer.exe'msiexec/iC:\Windows\Temp\java-installer.msi/quiet`ADDLOCAL="FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome,FeatureOracleJavaSoft"`INSTALLDIR=`"$javapath`"C:\Windows\Temp\agent-installer.exe/S/JAVA_PATH=`"$javapath`"/START_SERVICE=1/PORT=9051/D=C:\ProgramFiles\avantra}-ArgumentList$javaurl,$agenturl,$javapathRemove-Item-path'C:\Windows\Temp\java-installer.msi'Remove-Item-path'C:\Windows\Temp\agent-installer.exe'Remove-PSSession$session
Comments (1)
Heiko MannherzAccount Deactivated
There are a few things to consider:
You need to have enabled PowerShell Remoting. This is probably easiest in an Active Directory environment. If you don’t have enabled it, it is likely the setup of PowerShell Remoting takes more time than installing the Avantra Agents everywhere.
You need to set the Execution Policy on the computer you intend to run the script appropriately: Check if your security policies allow such a change. You may consider the value RemoteSigned.
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.
There are a few things to consider:
RemoteSigned
.