######################## # IMPORTANT # # This script requires elevated privileges (Run PowerShell as Admin) to run. # If you are deploying it via GPO or any other RMM, they will already run it in elevated mode, unless specifically configured otherwise. # However, if you run it locally as a user, you must make sure your PowerShell instance is elevated (Run PowerShell as Admin), otherwise the script will fail. # This script can be used both locally and with GPO or any other RMM that support PowerShell. However, some specific RMMs only support limited PowerShell commands, so this script might not work on these. In this case, please contact Coro support for help. ######################## #Add the Coro installation URL below (in between quotes ""). You can obtain the URL from your Coro Workspace (go to Control Panel -> Devices. Scroll down #to the latest Windows version, select the Actions button, then select Copy URL. From the Copy Invite Link dialog, select Copy.) Finally, paste the URL below. $url = "Add the Coro installation URL obtained from Coro Workspace here. Do not delete the quotes" #The URL above contains a string named CoroInstaller_XXXXX-XXXXX-XXXXX-XXXXX-XXXXX.msi (where X represents random numbers). Paste this string below (in between quotes ""). $newFilename = "Add the Coro msi package from the URL here. For example, CoroInstaller_1b16c978-cd39-49bf-8809-7b4e87227e4e.msi. Do not delete the quotes" ########################### # FOR SPECIFIC CASES ONLY # #Set the variable below to $false if you want the script to bypass Coro installation check. #This might be useful in some specific cases when it is required to reinstall Coro over the corrupted version. #However, please note that this method not work in all cases. In such cases Coro needs to be uninstalled first and then reinstalled. $checkCoroInstall = $true #Use only when asked to do so by Support: set this variable to $false to instruct the script bypass Coro installation check. ########################################################### ##### NO NEED TO AMEND ANYTHING ELSE BELOW THIS LINE ###### ########################################################### #Checking for elevated permissions $isElevated = [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) $isUserContext = -not ([Environment]::UserInteractive -and $isElevated) if (-not $isElevated -and $isUserContext) { Write-Host "" Write-Host "This script is not running in elevated mode. Please run Powershell as Administrator and execute this script." -ForegroundColor Cyan Write-Host "The script will now terminate as it cannot run without elevated permissions." -ForegroundColor Cyan Start-Sleep -Seconds 7 exit 1 } else { Write-Host "This instance is elevated, proceeding to the next step" -ForegroundColor Green Write-Host "" } #Display OS version try { Write-Host "" Write-Host "" $operatingSystem = Get-CimInstance -ClassName Win32_OperatingSystem $osVersion = $operatingSystem.Version $osEdition = $operatingSystem.Caption $osArchitecture = $operatingSystem.OSArchitecture $OSVersion = "$osEdition $osArchitecture $osVersion" Write-Host "### $OSVersion ###" Write-Host "" } catch { } #Set variables Write-Host "Configuring variables" $logFilePath = "C:\Windows\Temp\CoroInstallerlog.txt" $msiFilePath = "C:\Windows\Temp\$newFilename" $folder = "C:\Program Files\Coro Cyber Security Ltd\Coro" $file1 = "C:\Program Files\Coro Cyber Security Ltd\Coro\coronet-agent.exe" #CoroAgent1SRV $file2 = "C:\Program Files\Coro Cyber Security Ltd\Coro\CsAgent\csagent.exe" #CoroAgent2SRV $file3 = "C:\Program Files\Coro Cyber Security Ltd\Coro\user_working_dir\Coro.exe" #Coro UI $file4 = "C:\Program Files\Coro Cyber Security Ltd\Coro\coro-agent-s.exe" #CoroAgent3SRV $file5 = "C:\Program Files\Coro Cyber Security Ltd\Coro\coro-agent-w.exe" #CoroAgent5SRV Write-Host "Done!" -ForegroundColor Green #Check if Coro is installed if ($checkCoroInstall -ne $false) { Write-Host "" Write-Host "Checking if Coro is already installed" $installed = $false $present1 = $false $present2 = $false $present3 = $false $present4 = $false $present5 = $false if (Test-Path -Path $folder -PathType Container) { $folderPresent = $true Write-Host "" Write-Host "$folder folder is detected" -ForegroundColor Yellow Write-Host "The script will check further" -ForegroundColor Yellow } else { $folderPresent = $false Write-Host "Done! Coro is not installed, the script will carry on" -ForegroundColor Green } if ($folderPresent -ne $false) { if (Test-Path -Path $file1 -PathType Leaf) { $present1 = $true } if (Test-Path -Path $file2 -PathType Leaf) { $present2 = $true } if (Test-Path -Path $file3 -PathType Leaf) { $present3 = $true } if (Test-Path -Path $file4 -PathType Leaf) { $present4 = $true } if (Test-Path -Path $file5 -PathType Leaf) { $present5 = $true } if ($present1 -and $present2 -and $present3 -and $present4 -and $present5) { $installed = $true Write-Host"" Write-Host "Coro is already installed. The script will terminate now" -ForegroundColor Cyan Start-Sleep -Seconds 7 exit 1 } elseif ($present1 -or $present2 -or $present3 -or $present4 -or $present5) { $installed = $false Write-Host"" Write-Host "Coro is installed, but the following critical file(s) is/are missing:" -ForegroundColor Yellow Write-Host "" if (!$present1) { Write-Host " - $file1 (CoroAgent1SRV)" -ForegroundColor Yellow} if (!$present2) { Write-Host " - $file2 (CoroAgent2SRV)" -ForegroundColor Yellow} if (!$present3) { Write-Host " - $file3 (CoroUI service)" -ForegroundColor Yellow} if (!$present4) { Write-Host " - $file4 (CoroAgent3SRV)" -ForegroundColor Yellow} if (!$present5) { Write-Host " - $file5 (CoroAgent5SRV)" -ForegroundColor Yellow} Write-Host "" Write-Host "The script will still attempt to install Coro" -ForegroundColor Green Write-Host "If the installation fails, please uninstall Coro and retry" -ForegroundColor Green } else { $installed = $false Write-Host "Done! Coro is not installed, the script will carry on" -ForegroundColor Green } } } else { $installed = $false } if ($installed -ne $true) { #Download Coro installer Write-Host "" Write-Host "Downloading Coro installer. This might take some time, depending on download speed" $webClient = New-Object System.Net.WebClient try { $webClient.DownloadFile($url, $msiFilePath) Write-Host "Done! The installer is placed in C:\Windows\Temp" -ForegroundColor Green } catch { $errorMessage = $_.Exception.Message if ($errorMessage -like "*Could not find file*") { Write-Host "" Write-Host "Download error." -ForegroundColor Cyan Write-Host "Make sure Coro download URL and MSI file name are properly entered in `$url and `$newFilename variables in the script." -ForegroundColor Cyan Write-Host "Retry the script after checking." -ForegroundColor Cyan Write-Host "" Write-Host "If the error persists, please contact Support and provide a screenshot of this message." -ForegroundColor Cyan } elseif ($errorMessage -like "*The path is not of a legal form*") { Write-Host "" Write-Host "Download error. Error code: The path is not of a legal form." -ForegroundColor Cyan Write-Host "" Write-Host "Make sure the `$newFilename and `$url variables are not empty" -ForegroundColor Cyan Write-Host "Retry the script after checking." -ForegroundColor Cyan Write-Host "" Write-Host "If the error persists, please contact Support and provide a screenshot of this message." -ForegroundColor Cyan } elseif ($errorMessage -like "*Value cannot be null*") { Write-Host "" Write-Host "Download error. Error code: Value cannot be null. Parameter name: address." -ForegroundColor Cyan Write-Host "" Write-Host "Make sure the `$url variable is not renamed in the script." -ForegroundColor Cyan Write-Host "Retry the script after checking." -ForegroundColor Cyan Write-Host "" Write-Host "If the error persists, please contact Support and provide a screenshot of this message." -ForegroundColor Cyan } elseif ($errorMessage -like "*An exception occurred during a WebClient request*") { Write-Host "" Write-Host "Download error. Error code: An exception occurred during a WebClient request." -ForegroundColor Cyan Write-Host "" Write-Host "Make sure the `$newFilename variable is not renamed in the script and that it contains the correct name of Coro MSI file." -ForegroundColor Cyan Write-Host "Retry the script after checking." -ForegroundColor Cyan Write-Host "" Write-Host "If the error persists, please contact Support and provide a screenshot of this message." -ForegroundColor Cyan } else { Write-Host "" Write-Host "Error when downloading. Error message: $errorMessage" -ForegroundColor Cyan Write-Host "" Write-Host "Please contact Support and provide a screenshot of the error" -ForegroundColor Cyan } Start-Sleep -Seconds 10 exit 1 } $webClient.Dispose() #Install the downloaded file try { Write-Host "" Write-Host "Installing Coro" $coroInstall = Start-Process msiexec.exe -PassThru -Wait -ArgumentList "/i `"$msiFilePath`" /qn /L*V `"$logFilePath`"" $exitCode = $coroInstall.ExitCode if ($exitCode -eq 0) { Write-Host "Done! It is recommended to reboot your machine to finalise the install" -ForegroundColor Green Start-Sleep -Seconds 1 $success = $true } elseif ($exitCode -eq 1619) { Write-Host "Installation failed because of value of `$msiFilePath variable" -ForegroundColor Cyan Write-Host "" Write-Host "Please check the `$msiFilePath variable in the script" -ForegroundColor Cyan Write-Host "If the variable is correct, then this is something else" -ForegroundColor Cyan Write-Host "" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send $logFilePath log file along with a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } elseif ($exitCode -eq 1612) { Write-Host "Installation failed because the installation source is not available" -ForegroundColor Cyan Write-Host "" Write-Host "This often happens when Coro was already deployed via GPO/RMM in a wrong way (msi package renamed)" -ForegroundColor Cyan Write-Host "So please check GPO/RMM to ensure it is not pushing any Coro install policy to this device" -ForegroundColor Cyan Write-Host "After that, it is recommended to run the Uninstall script to delete all registry leftovers" -ForegroundColor Cyan Write-Host "Re-run this script after that" -ForegroundColor Cyan Write-Host "" Write-Host "If the error persists after all this, then this is something else" -ForegroundColor Cyan Write-Host "" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send $logFilePath log file along with a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } elseif ($exitCode -eq 1639) { Write-Host "Installation failed because of incorrect argument(s) of ArgumentList argument" -ForegroundColor Cyan Write-Host "" Write-Host "Please check the script" -ForegroundColor Cyan Write-Host "" Write-Host "If the argument is correct, then this is something else" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } elseif ($exitCode -eq 1603 -and $checkCoroInstall -ne $true) { Write-Host "Installation failed" -ForegroundColor Cyan Write-Host "" Write-Host "Make sure the script is running in Elevated mode (Run PowerShell as Admin)" -ForegroundColor Cyan Write-Host "Also, make sure Coro's registry hive is present in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products" -ForegroundColor Cyan Write-Host "If you just uninstalled Coro by any means, please reboot first and then run this script again" -ForegroundColor Cyan Write-Host "If the issue still persists, then there is some other corruption. Try to run the Uninstall script and retry" -ForegroundColor Cyan Write-Host "" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } elseif ($exitCode -eq 1603) { Write-Host "Installation failed" -ForegroundColor Cyan Write-Host "" Write-Host "Make sure the script is running in Elevated mode (Run PowerShell as Admin)" -ForegroundColor Cyan Write-Host "If you just uninstalled Coro by any means, please reboot first and then run this script again" -ForegroundColor Cyan Write-Host "If the issue still persists, then there is some other corruption. Try to run the Uninstall script and retry" -ForegroundColor Cyan Write-Host "" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } elseif ($exitCode -eq 1625) { Write-Host "Installation failed" -ForegroundColor Cyan Write-Host "" Write-Host "This often occurs when Coro is already installed but corrupted" -ForegroundColor Cyan Write-Host "Try to remove existing version of Coro via Control Panel or Uninstall script" -ForegroundColor Cyan Write-Host "If the issue still persists, then there is something else" -ForegroundColor Cyan Write-Host "" Write-Host "Error code: $exitCode" -ForegroundColor Cyan Write-Host "Please contact Support and send a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } else { Write-Host "Installation failed, error code: $exitCode" -ForegroundColor Cyan Write-Host "" Write-Host "If Coro was ever installed on this machine, please first run the Uninstall script to clear all the leftovers and then retry." Write-Host "Please contact Support and send $logFilePath log file along with a screenshot of this output" -ForegroundColor Cyan Remove-Item -Path $msiFilePath -Force -Confirm:$false Start-Sleep -Seconds 10 exit 1 } } catch { } #Delete installation files if ($success -eq $true) { Write-Host "" Write-Host "Deleting installation and log files as they are no longer required" if (Test-Path -Path $logFilePath) { Remove-Item -Path $logFilePath -Force -Confirm:$false } if (Test-Path -Path $msiFilePath) { Remove-Item -Path $msiFilePath -Force -Confirm:$false } Write-Host "Done!" -ForegroundColor Green Write-Host "" Write-Host "Coro has been installed successfully" -ForegroundColor Green Start-Sleep -Seconds 5 } else { } } else { }