Deployment of Google Remote Desktop

  • 26 March 2020
  • 8 replies
  • 257 views

Badge

I threw this together for my org to get some easy remote support tools in place. Just wanted to post it here if someone else found it useful or could do a better job 😉


Evaluation Code:


#REQUIRES -Version 2.0
<#
.SYNOPSIS
This Test script checks to see if Chrome is installed
.DESCRIPTION
This script queries the installed files for 32 and 64bit software
and returns 0 if product is installed or 1 if not
.Notes
File Name :ChromeRemoteDesktop_Install_Test.ps1
Author :Automox
Prerequisite :PowerShell V2 over win7 and upper
#>
#Handle Exit Codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }
function ChromeRemoteDesktop_Install_Test {
[array]$key = Get-UninstallRegistryKey -SoftwareName "Chrome Remote Desktop Host"
$alreadyInstalled = $false
$version = '80.0.3987.18'

if ($key.Count -ne 0) {
$key | ForEach-Object {
if ($_.DisplayVersion -eq $version) {
$alreadyInstalled = $true
}
}
}

$packageArgs = @{
packageName = 'chrome-remote-desktop-host'
fileType = 'msi'
url = 'https://dl.google.com/dl/edgedl/chrome-remote-desktop/chromeremotedesktophost.msi'
checksum = '83730b9919ad2dd3a41a5d2af1cfeeee7f3cad04a557a70b8de7549233c3a243'
checksumType = 'sha256'
silentArgs = '/qn /norestart'
validExitCodes = @(0)
softwareName = 'Chrome Remote Desktop Host'
}

if ($alreadyInstalled) {
#Application Found, Automox can handle the updates!
exit 0
} else {
# Application is not installed! Run Remediation Script to install it.
exit 1
}
}

ChromeRemoteDesktop_Install_Test

Remediation code:


#REQUIRES -Version 2.0
<#
.SYNOPSIS
This script allows an admin to install Google chrome remote desktop.
.DESCRIPTION
This script downloads the installer into C:\ProgramData\amagent, executes it silently, and cleans up.
This is an example script that has been tested to work on Win10 and Win7.
This script may not work on all systems. Modify to fit your needs
.NOTES
File Name :Chrome_Install.ps1
Author :Automox
Prerequisite :PowerShell V2 over win7 and upper
#>
#Handle Exit codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }

function ChromeRemote_Install
{

<#
.SYNOPSIS
This function Installs the latest version of Chrome on Windows.
This Remediation Script will run as scheduled when the associated Evaluation is Non-Compliant.
.DESCRIPTION
This function download and installs the latest version of Chrome on Windows.
This script downloads the latest Chrome installer to C:\ProgramData\amagent.
After execution, files are cleaned up..
The temporary working directory will be cleaned up after execution.
Output can be viewed in the agent log (C:\ProgramData\amagent\amagent.log).
Or in the Automox Activity Log in the Reports section..
.EXAMPLE
Chrome_Install
.NOTES
#>

#User can Change the settings in this block
$saveFilePath = "$PSScriptRoot\chromeremotedesktophost.msi"
$url = "https://dl.google.com/dl/edgedl/chrome-remote-desktop/chromeremotedesktophost.msi"

# Clean up pre-existing installer files in the same location
if (Test-Path -Path "$saveFilePath") {
Remove-Item -force "$saveFilePath" -ErrorAction SilentlyContinue
}
# Download the ChromeRemoteDestkop installer file.
$downloader = (new-object System.Net.WebClient)
Try {
$downloader.DownloadFile("$url", "$saveFilePath")
Write-Output "ChromeRemoteDesktop Installer download finished..."
}
Catch {
Write-Output "File download failed. Check URL [$url] and try again."
exit 90
}

# Start Installation
Try {
$process = Start-Process -FilePath "$saveFilePath" -ArgumentList "/qn /norestart" -Wait -PassThru -ErrorAction Stop;
Write-Output "Chrome Installion Finished..."
}
Catch { $Exception = $error[0].Exception.Message + "`nAt Line " + $error[0].InvocationInfo.ScriptLineNumber
Write-Output $Exception
exit 90
}

# Avoid error while deleting the installer as process of installation is in progress.
# Wait till installer finished its process completed.
do {
if ((Get-Content $saveFilePath)) {
Write-Output "Installer complete...cleaning up installation files"
Remove-Item -force "$saveFilePath" -ErrorAction SilentlyContinue
exit $process.ExitCode
} else {
Write-Output "Waiting for Installer File Unlock"
}
$fileunlocked = 1
} Until ($fileunlocked)

}

ChromeRemote_Install

8 replies

Badge

I also set this up to not be scheduled, but to run if missed. Then I simply ran it manually. All currently connected machines received it and all others got it the next morning ! I must admit Automox is a GREAT tool to have!!

Userlevel 7

Thanks for sharing this and for the kind words about Automox!

Userlevel 7

Does this worklet require Chocolately to run? It looks like this command isn’t a built-in Powershell command:

Badge

No it does not, I was just using that as a base to handle the scripting pieces. I have found Chocolatey to be a great starting point for deployment scripts as you can easily modify any of the deployment scripts to fit with another deployment package that uses powershell.

Userlevel 7

We are running into issues with the Get-UninstallRegistryKey command in the evaluation code. Is there an alternate command for that which is built in to powershell?

Badge

Ahh, I see what your talking about. Yeah we should be able to find this same information using something else. I will play with it a bit to see if I can find something that will work without giving an error.

Userlevel 7

Thanks! Alternately we can put Chocolatey as a pre-requisite, if there’s no simple command to substitute.

Badge

I think this will work (Can not test it yet in a deployment, but was able to evaluate it as working from a local system.)


function ChromeRemoteDesktop_Install_Test {

[array]$key = Get-WmiObject -Class Win32_Product | where Name -eq "Chrome Remote Desktop Host"

$version = '85.0.4183.6'

if ($key.count -ne 0) {

$key | ForEach-Object {

if ($_.Version -eq $version) {

$alreadyInstalled = $true

}

}

}

if ($alreadyInstalled) {

exit 0

} else {

exit 1

}

}

ChromeRemoteDesktop_Install_Test

Reply