Skip to main content

Worklet: Install Slack on Windows


Nic-Automox

Installs Slack on Windows.

Evaluation code:

#REQUIRES -Version 2.0
<#
.SYNOPSIS
    This Test script checks to see if Slack is installed
.DESCRIPTION
    This script queries the installed files for 32 and 64bit software
    and returns a 0 if product is installed or 1 if not
.Notes
    File Name       :Slack_Install_Test.ps1
    Author          :Automox
    Prerequisite    :PowerShell V2 over win7 and upper
#>
#Handle Exit Codes:
trap {  $host.ui.WriteErrorLine($_.Exception); exit 90 }

function Slack_Install_Test {

	<#
    .SYNOPSIS
        This function Checks for the Slack is Installed on system or not .
    .DESCRIPTION
        After checking the Slack availability, based on the exit code tool will decide to call remediation code or not.
    .EXAMPLE
        Slack_Install_Test
    .NOTES
    #>

	# Name of the desired application.
	$appName = 'Slack'
	# Finding the Systen Directory (system32 Directory).
	$sysDir = [Environment]::SystemDirectory

	# Making the 32 bit and 64 bit path names blank.
	$32BIT = ""
	$64BIT = ""

	#Get Registry value for the 32 bit software installed on both 32-bit and 64-bit machine
	Try {  $32BIT = Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction Stop |
			Select-Object DisplayName |
			Select-String "$appName" |
			Out-String
	}
	Catch { $Exception = $error[0].Exception.Message + "`nAt Line " + $error[0].InvocationInfo.ScriptLineNumber;
			Write-Output $Exception
			exit 90
	}
	# Script blcok to execute with powershell
	# Match name in the block should be hard coded.
	$scriptBlock = {$key = Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' |
					Where-Object { $_.DisplayName -match 'Slack'}
					return $key
					}

	# Get the Registry value for the 64 bit software installed on the 64 bit machine. as the automox process is 32 bit
	if ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit")
	{
		# Call for accessing the 64 bit registry incase 32 bit process not access the registry.
		Try
		{
			$installed64 = @(& "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptBlock)
			$64BIT = $installed64.DisplayName
		}
		Catch
		{
			$Exception = $error[0].Exception.Message + "`nAt Line " + $error[0].InvocationInfo.ScriptLineNumber;
			Write-Output $Exception
			exit 90
		}

	}
	# Check for the Availability of the software and exit with relevent exit code.
	if ($32BIT.Trim() -match $appName -or ($64BIT -ne $null -and $64BIT.Trim() -match $appName)) {
		#Application Found, Automox can handle the updates!
		exit 0
	} else {
		# Application is not installed! Run Remediation Script to install it.
		exit 1
	}
}

Slack_Install_Test

Remediation code:

#REQUIRES -Version 2.0
<#
.SYNOPSIS
    This script allows an admin to install Slack
.DESCRIPTION
    This script downloads the system-wide-slack installer. Once installed, the program
    checks to see if slack is installed WHEN A USER LOGS IN. If slack is not installed
    the program installs it in the packground.
    If a user has uninstalled slack, this will not reinstall it.
.NOTES
    File Name       :Slack_Install.ps1
    Author          :Automox
    Prerequisite    :PowerShell V2 over win7 and upper
#>
#Handle Exit Codes:
trap {  $host.ui.WriteErrorLine($_.Exception); exit 90 }

function Slack_Install{

    <#
    .SYNOPSIS
        This function allows automox to Install the Slack on Windows .
    .DESCRIPTION
        This function download and installs the latest version of Slack on system.
    .EXAMPLE
        Slack_Install
    .NOTES
    #>

    #############Change the settings in this block#######################
    # Save the installer in the powershell current working directory.
    $saveFilePath = "$PSScriptRoot\SlackSetup.msi"
	
	# If any old installer file is existed, Delete the old installer.
    if (Test-Path -Path "$saveFilePath") {
		Remove-Item -force "$saveFilePath" -ErrorAction SilentlyContinue
    }

    # Download msi Installer based on the bit version of the Windows OS
    if ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit") {
        $URL = "http://slack.com/ssb/download-win64-msi"
    } else  {
        $URL = "http://slack.com/ssb/download-win-msi"
    }

    ###### Download the msi installer file for the installation ######
    $downloader = (new-object System.Net.WebClient)
    Try {
        $downloader.DownloadFile("$URL", "$saveFilePath")
        Write-Output "Slack Installer download finished..."
    }
    Catch { Write-Output "File download failed. Check URL [$URL] and try again."
            exit 90
    }

    ###### Installing  slack on system ######
    Try {
        $process=Start-Process -FilePath msiexec.exe -ArgumentList '/i',$saveFilePath,'/q' -Wait -PassThru -ErrorAction Stop
        Write-Output "Slack 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 it is still in the process of installation.
    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)

}

Slack_Install

  • Rookie
  • February 11, 2020

Would you do a version for Zoom?

https://www.zoom.us/client/latest/ZoomInstallerFull.msi


Nic-Automox
  • Former Automox Employee
  • February 11, 2020

You should actually be able to do that with a required software policy. That will check to make sure Zoom is installed and install it if it is missing. If that won’t work for you let me know and I can look into making a worklet version instead.


  • Rookie
  • February 11, 2020

Thanks Nic!


Nic-Automox
  • Former Automox Employee
  • February 11, 2020

In case you haven’t done a required software policy before, you just need the installer, and then the name and version number that shows up in Add/Remove programs once it’s installed. Once you have those, put them in the required software policy and it checks against the Add/Remove programs DB automatically, and then runs the installer command if it is missing. We now updated Zoom as a 3rd party app, so you don’t need to make sure that they’re on the latest version. Here’s the KB with all the details and screenshots:

https://support.automox.com/help/how-to-find-application-names-and-versions-for-required-software-policies

https://support.automox.com/help/creating-a-required-software-policy

If you run into any problems let me know and I or support can help you out.


  • Rookie
  • February 11, 2020

It didn’t seem to work. What would the installation command look like if this is what it normally looks like?

msiexec /i ZoomInstallerFull.msi /quiet /qn /norestart /log install.log


Nic-Automox
  • Former Automox Employee
  • February 11, 2020

Yep you can just put that command with all the flags into the installer window. Note that you have to click on the icon in the upper right to edit that installer window (the other code blocks don’t have that, so I mention it because I always forget and try to paste in there without clicking the button first, and then start wondering why my copy paste isn’t working).


Nic-Automox
  • Former Automox Employee
  • February 11, 2020

This thread also has some details on getting it to work. It’s for a specific use case and might be more detail than you need, but I’m linking it in case it helps:


  • June 5, 2020

How would you create an evaluation that could check zoom version? I was able to successfully setup pushing Zoom to macs but the evaluation only looks for whether or not Zoom exists. Since zoom constantly releases updates I would like to be able to keep the clients up to date by using the same worklet.


Nic-Automox
  • Former Automox Employee
  • June 5, 2020

You could use a required software policy for that, where it checks against the currently installed version to see if it needs to install a higher version. For the package name you’d put in zoom.us and then the version number as it appears in add/remove programs (e.g. 4.4.53932.0709). Would that work?

Also, Zoom is one of the third party titles that we automatically update, so the patching policy should catch that and keep your endpoints up to date.


  • June 5, 2020

This is actually for mac deployment. I don’t think Macs have the add/remove program unless I don’t know where to find them.


Nic-Automox
  • Former Automox Employee
  • June 5, 2020

oh right, sorry - rather than add/remove programs, what shows on the software page after you install Zoom.


  • June 5, 2020

Where would that go in the code below? Or better yet could you just bypass the eval code?

#!/bin/bash

if [ -d “/Applications/zoom.us.app” ]; then
exit 0
else
exit 1
fi


Nic-Automox
  • Former Automox Employee
  • June 5, 2020

If you use a Required Software Policy instead of a Worklet then there is no (visible) evaluation code. It takes the package name and the version number and looks that up on the endpoint to see whether it should return 0 or 1 after it determines whether the software is installed or not:


Forum|alt.badge.img

Hello I’m fairly new to Automox and just trying to get a handle on getting some common applications installed through Automox such as Slack, Zoom, Google Chrome, and Firefox.  I copy/pasted the above when trying to create a Worklet to install Slack on Windows.  When running the policy and I check the logs, it says it timed out.  Any thoughts?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings