## Set the activation code of the installation group 
$ActivationCode = 'AWrRT9wP'

## Set the shared path of the Agent installation file 
$LumuShare = 'https://artifacts.lumu.io/lum_agent_offline.exe' 

## Set the Lumu Portal credentials <Not admin needed, they can be a standard user>
$user = 'MyUser@lumu.io'
$pass = 'MyPass'

#####################################################################
###################  Do not change the following lines ######################
#####################################################################

## Lumu Service Name
$LocalInstaller = 'C:\Temp\lum_agent_offline.exe'
$LocalInstallerCheck = Test-Path 'C:\Temp\lum_agent_offline.exe'
$AgentPath = Test-Path 'C:\Program Files (x86)\Lumu\Agent\lumu-windows-agent.exe'

## Check if the installation file already exist, if not, copy it
if (!$LocalInstallerCheck) {
New-Item -Path 'C:\Temp\' -ItemType Directory
$secpass = ConvertTo-SecureString -String $pass -AsPlainText -Force
$credentials  = New-Object System.Management.Automation.PSCredential ($user,$secpass)
Invoke-WebRequest -Uri $LumuShare -OutFile "C:\temp\lum_agent_offline.exe" -Credential $credentials 
}

## Check if Lumu Agent is already installed, if not, install it with the defined activation code
if (!$AgentPath) { 
Start-Process $LocalInstaller -ArgumentList "/SP- /VERYSILENT /activationcode=$ActivationCode /acceptlicense='true'"
}