@@ -10,42 +10,44 @@ Param (
10
10
# --- Modify Below This Line At Your Own Risk ------------------------------
11
11
12
12
# JumpCloud Agent Installation Variables
13
+ $TempPath = ' C:\Windows\Temp\'
13
14
$AGENT_PATH = Join-Path ${env: ProgramFiles} " JumpCloud"
14
15
$AGENT_BINARY_NAME = " jumpcloud-agent.exe"
15
16
$AGENT_INSTALLER_URL = " https://cdn02.jumpcloud.com/production/jcagent-msi-signed.msi"
16
17
$AGENT_INSTALLER_PATH = " C:\windows\Temp\jcagent-msi-signed.msi"
17
18
# JumpCloud Agent Installation Functions
18
19
Function InstallAgent () {
19
- if (! (Test-Path " C:\ProgramData\JumpCloud\Agent" )) {
20
- New-Item - ItemType Directory - Path " C:\ProgramData\JumpCloud\Agent" - Force
21
- }
22
- msiexec / i $AGENT_INSTALLER_PATH / quiet / norestart JCINSTALLERARGUMENTS= `" - k $JumpCloudConnectKey `" / L* V " C:\ProgramData\JumpCloud\Agent\jcUpdate.log"
20
+ msiexec / i $AGENT_INSTALLER_PATH / quiet JCINSTALLERARGUMENTS= `" - k $JumpCloudConnectKey / VERYSILENT / NORESTART / NOCLOSEAPPLICATIONS / L* V " C:\Windows\Temp\jcUpdate.log" `"
23
21
}
24
22
Function DownloadAgentInstaller () {
25
23
(New-Object System.Net.WebClient).DownloadFile(" ${AGENT_INSTALLER_URL} " , " ${AGENT_INSTALLER_PATH} " )
26
24
}
27
25
Function DownloadAndInstallAgent () {
28
- Write-Output ' Downloading JCAgent Installer'
29
- # Download Installer
30
- DownloadAgentInstaller
31
- Write-Output ' JumpCloud Agent Download Complete'
32
- Write-Output ' Running JCAgent Installer'
33
- # Run Installer
34
- InstallAgent
35
-
36
- # Check if agent is running as a service
37
- # Do a loop for 5 minutes to check if the agent is running as a service
38
- # The agent pulls cef files during install which may take longer then previously.
39
- for ($i = 0 ; $i -lt 300 ; $i ++ ) {
40
- Start-Sleep - Seconds 1
41
- # Output the errors encountered
42
- $AgentService = Get-Service - Name " jumpcloud-agent" - ErrorAction SilentlyContinue
43
- if ($AgentService.Status -eq ' Running' ) {
44
- Write-Output ' JumpCloud Agent Succesfully Installed'
45
- exit
26
+ If (Test-Path - Path " $ ( $AGENT_PATH ) \$ ( $AGENT_BINARY_NAME ) " ) {
27
+ Write-Output ' JumpCloud Agent Already Installed'
28
+ } else {
29
+ Write-Output ' Downloading JCAgent Installer'
30
+ # Download Installer
31
+ DownloadAgentInstaller
32
+ Write-Output ' JumpCloud Agent Download Complete'
33
+ Write-Output ' Running JCAgent Installer'
34
+ # Run Installer
35
+ InstallAgent
36
+
37
+ # Check if agent is running as a service
38
+ # Do a loop for 5 minutes to check if the agent is running as a service
39
+ # The agent pulls cef files during install which may take longer then previously.
40
+ for ($i = 0 ; $i -lt 300 ; $i ++ ) {
41
+ Start-Sleep - Seconds 1
42
+ # Output the errors encountered
43
+ $AgentService = Get-Service - Name " jumpcloud-agent" - ErrorAction SilentlyContinue
44
+ if ($AgentService.Status -eq ' Running' ) {
45
+ Write-Output ' JumpCloud Agent Succesfully Installed'
46
+ exit
47
+ }
46
48
}
49
+ Write-Output ' JumpCloud Agent Failed to Install'
47
50
}
48
- Write-Output ' JumpCloud Agent Failed to Install'
49
51
}
50
52
51
53
# Flush DNS Cache Before Install
0 commit comments