Category Archive Script Repository

ByDan Ashley

SCRIPT | Install-TableauDesktop-Latest

Install Tableau Desktop

Summary

This script will install the latest version of Tableau Desktop.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="TableauDesktop.dmg"
pkgname="Tableau Desktop.pkg"
apptoreplacerunningname="Tableau"

# Determine CPU architecture for download
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then
	dmglink="https://www.tableau.com/downloads/desktop/mac-arm64"
	echo "Running process to download arm64 version"
else
	dmglink="https://www.tableau.com/downloads/desktop/mac"
	echo "Running process to download x86_64 version"
fi

# Download DMG
curl -L -o $dmgname "$dmglink"

# Mount DMG
hdiutil mount -nobrowse $dmgname

# Grab the name of the mounted .dmg as it changes with each version
dmgmountedname=`ls /Volumes | grep "Tableau"`
echo "The DMG mounted is: $dmgmountedname"

# Grab the name of the currently installed Tableau version, if present, as it changes with each version.
cd "/Applications"
apptoreplace=`ls | grep "Tableau"`

# If Tableau Desktop is already installed, remove it prior to installing the latest version.
if [ "$apptoreplace" != "" ]; then
	echo "The currently installed Tableau application is: $apptoreplace"
	# Kill the app if it is running
	echo "Killing the app if it is running..."
	killall -Kill "$apptoreplacerunningname"
	echo "Removing /Applications/$apptoreplace prior to installing..."
	rm -rf "/Applications/$apptoreplace"
else
	echo "No existing versions of Tableau Desktop detected."
fi

# Install the PKG from the DMG
sudo installer -pkg "/Volumes/$dmgmountedname/$pkgname" -target /

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
cd "/Library/Application Support/JAMF/tmp"
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset pkgname
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
exit 0

Concluding Comments

This script will install the latest version of the Tableau Desktop application.

ByDan Ashley

SCRIPT | Install-NordVPN-Latest

Install NordVPN

Summary

This script will install the latest version of NordVPN.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
pkgname="NordVPN.pkg"
pkglink="https://downloads.nordcdn.com/apps/macos/generic/NordVPN-OpenVPN/latest/NordVPN.pkg"
apptoupdaterunningname="NordVPN"

# Download PKG
curl -L -o "$pkgname" "$pkglink"

sleep 10

# Kill the app if it is running
killall -Kill "$apptoupdaterunningname"

# Install PKG
sudo installer -pkg $pkgname -target /

# Remove the downloaded PKG
rm $pkgname

# Clear out the used variables
unset pkgname
unset pkglink
unset apptoupdaterunningname
exit 0

Concluding Comments

This script will install the latest version of the NordVPN application.

ByDan Ashley

SCRIPT | Install-ParallelsDesktop26-Latest

Install Parallels Desktop 26

Summary

This script will install the latest version of Parallels Desktop 26.


Script Content

#!/bin/bash

cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
	dmgName="ParallelsDesktop.dmg"
	dmgLink="https://link.parallels.com/pdfm/v26/dmg-download/?experience=enter_key"
	appRunningName="Parallels Desktop"
	appServiceRunningName1="prlctl"
	appServiceRunningName2="prl_client_app"
	appName="Parallels Desktop.app"


# Parallels Desktop license key
	# Uncomment 'licenseKey' variable below and add license key to enable activation
	#licenseKey="XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX"


# Download latest Parallels Desktop DMG
	echo "Downloading latest Parallels Desktop DMG..."
	curl -L -o $dmgName "$dmgLink"


# Mount the Parallels Desktop .DMG
	echo "Mounting $dmgName..."
	hdiutil mount -nobrowse $dmgName

	# Grab the name of the mounted .dmg as it changes with each version
	dmgMountedName=`ls /Volumes | grep "Parallels"`
	echo "The DMG mounted is: $dmgMountedName"


# Check to see if Parallels Desktop is install, then if it is ensure it is not running
	echo "Checking for any existing installation of Parallels Desktop..."

	if [ -d "/Applications/$appName" ]; then
		ParallelsVersion=`defaults read "/Applications/$appName/Contents/version.plist" CFBundleShortVersionString` 
		echo "The currently installed version of Parallels Desktop is v$ParallelsVersion"

		# Kill the app if it is running
		echo "Killing the app if it is running..."
		killall -Kill "$appRunningName"
		killall -Kill "$appServiceRunningName1"
		killall -Kill "$appServiceRunningName2"
		rm -rf "/Applications/$appName"
	else
		echo "No existing versions of Parallels Desktop detected."
	fi


# Install Parallels Desktop from DMG
	echo "Starting Parallels Desktop installation..."

	"/Volumes/$dmgMountedName/$appName/Contents/MacOS/inittool" install -t "/Applications/$appName" -s

	if [ -d "/Applications/$appName" ]; then
		ParallelsVersion=`defaults read "/Applications/$appName/Contents/version.plist" CFBundleShortVersionString`
		echo "Parallels Desktop version $ParallelsVersion is now installed."
	else
		echo "Parallels Desktop has failed to install correctly."
		exit 1
	fi


# Activate Parallels Desktop license
	echo "Determining license activation method..."

	if [ "$licenseKey" != "" ]; then
		sudo prlsrvctl install-license -k $licenseKey
		echo "Parallels Desktop has been activated using license key."
	else
		echo "No license provided. Parallels Desktop will require activating manually upon use."
	fi


# Unmount the DMG
	hdiutil unmount "/Volumes/$dmgMountedName"


# Remove the downloaded DMG
	rm "/Library/Application Support/JAMF/tmp/$dmgName"


# Clear out the used variables
	unset dmgName
	unset dmgLink
	unset appRunningName
	unset appServiceRunningName1
	unset appServiceRunningName2
	unset appName
	unset licenseKey
	unset dmgMountedName
	unset ParallelsVersion

exit 0

Concluding Comments

This script will install the latest version of the Parallels Desktop 26 application.

ByDan Ashley

SCRIPT | Management-Rename-Mac

Rename Macs

Summary

This script will enforce naming Macs based upon their serial numbers.

In addition to using the serial number to form the bulk of the naming convention, the script will also determine wether a laptop or desktop Mac is being renamed. If the computer being renamed is a laptop then the serial number will be prefixed with “ML-” representing “Mac Laptop“. If the computer is determined to be a desktop computer then the serial number will be prefixed with “MD-” to signify “Mac Desktop“.
And finally, if the computer is determined to be a virtual machine then the serial number will be prefixed with “MV-” to signify “Mac Virtual Machine“.


Script Content

#!/bin/bash

isLaptop=`/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"`
isVM=`/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Virtual"`

if [ "$isLaptop" != "" ]; then
	NewMacName=`system_profiler SPHardwareDataType | grep "Serial Number (system)" | sed 's/Serial Number (system): /ML-/'`
	elif [ "$isVM" != "" ]; then
		NewMacName=`system_profiler SPHardwareDataType | grep "Serial Number (system)" | sed 's/Serial Number (system): /MV-/'`
	else
		NewMacName=`system_profiler SPHardwareDataType | grep "Serial Number (system)" | sed 's/Serial Number (system): /MD-/'`
fi

echo "Setting computer name as: $NewMacName"
scutil --set ComputerName $NewMacName
scutil --set HostName $NewMacName
scutil --set LocalHostName $NewMacName
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName $NewMacName
rm -f "$isLaptop"
rm -f "$isVM"
rm -f "$NewMacName"

Concluding Comments

By implementing this naming convention when working with a large number of Macs will ensure that all computer names are unique. In addition it will allow for easy identification of wether a Mac is a laptop or desktop model.

ByDan Ashley

SCRIPT | Install-Microsoft-VisualStudioCode-Latest

Install Microsoft Visual Studio Code

Summary

This script downloads the latest version of Visual Studio Code from the internet then installs the application. If the application is already installed, the previous version is removed prior to installing.


Script Content

#!/bin/bash
############################################################
#
# ABOUT THIS PROGRAM
#
# 	Downloads the latest version of Visual Studio Code from the internet then installs the
#	application. If the application is already installed, then previous version is removed
#	prior to installing.
#
#	Modified base script taken from:
#	https://www.jamf.com/jamf-nation/third-party-products/files/1035/auto-install-visual-studio-code
#
############################################################

# Script to download and install VS Code directly from the Internet

		# Assignment of global variables
		protocolDomain='https://code.visualstudio.com'
		zipfile="VSCode-darwin.zip"
		logfile="/Library/Logs/VSCodeInstallScript.log"

		# Begin writing to a log file
		/bin/echo "--" >> ${logfile}
		/bin/echo "Parsing through $protocolDomain in order to find the download URL for VSCode." >> ${logfile}

		# Find the release page for the new update
		newUpdatePage=$(curl $protocolDomain/updates)

		# Remove the redirection clause in order to obtain the URL for the new update page
		redirectClause='Found. Redirecting to '
		newUpdatePage=${newUpdatePage#${redirectClause}}

		# Find the download page for the specific new update and revision (NOTE: The download for the Linux URL is very similar to the Mac URL, and is therefore parsed from this page)
		linuxPath='/linux-x64/stable'
		linuxURL=$(curl $protocolDomain/$newUpdatePage | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep "$linuxPath")

		# Remove the path to the Linux download and replace it with the path to the Mac download
		latestUpdateURL=${linuxURL%${linuxPath}}
		macPath='/darwin/stable'
		macDownloadPage="$latestUpdateURL$macPath"

		# Curl the resulting download page. It redirects to the actual download URL for the zip file
		macDownloadURL=$(curl $macDownloadPage)
		url=${macDownloadURL#${redirectClause}}

		# Kill any open sessions of VSCode
		/bin/echo "Killing any open sessions of Visual Studio Code." >> ${logfile}
		osascript -e 'quit app "Code"'

		# Remove the previous version of VSCode
		/bin/echo "Removing the previous version of Visual Studio Code." >> ${logfile}
		rm -rf /Applications/Visual\ Studio\ Code.app

		# Download the latest version from the parsed url via 'curl'
		/bin/echo "`date`: Downloading latest version." >> ${logfile}
		/usr/bin/curl -s -o /tmp/${zipfile} ${url}

		# Unzip the compressed .app and move it to /Applications
		/bin/echo "Unzipping the compressed file of the latest version and moving it to /Applications." >> ${logfile}
		unzip /tmp/${zipfile} -d /Applications

		# Remove the leftover zip file from the /tmp cache
		/bin/echo "Removing the .zip file from /tmp." >> ${logfile}
		rm -f /tmp/${zipfile}

		# Change the permissions and owndership of the .app file in order to remove it from the 'Downloaded from Internet' quarantine
		/bin/echo "Removing new application from 'Downloaded from Internet' quarantine." >> ${logfile}
		chmod -R 755 /Applications/Visual\ Studio\ Code.app
		chown -R root:wheel /Applications/Visual\ Studio\ Code.app

exit 0

Concluding Comments

Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.

ByDan Ashley

SCRIPT | Install-RoyalTSX-5.0.6.1000

Install Royal TSX

Summary

This script will install the version 5.0.6.1000 of Royal TSX.

Although the script installs a static version of Royal TSX (in this case 5.0.6.1000), the script can easily be modified for new versions as they become available simply be editing the version number in the variables for the “dmgname” and the “dmglink“.


Script Content

#!/bin/zsh
cd "/Library/Application Support/JAMF/tmp"

# Update variables
dmgname="royaltsx_5.0.6.1000.dmg"
dmglink="https://royaltsx-v5.royalapps.com/updates/royaltsx_5.0.6.1000.dmg"
dmgmountedname="Royal TSX"
apptoreplace="Royal TSX.app"
apptoreplacerunningname="RoyalTSX"

# Download DMG
curl -L -O "$dmglink"

# Convert DMG to CDR to bypass EULA and mount DMG 
hdiutil convert $dmgname -format UDTO -o $dmgname.cdr
hdiutil mount -nobrowse $dmgname.cdr

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Copy the new version into the Applications Folder
cp -R "/Volumes/$dmgmountedname/$apptoreplace" /Applications

# Set the user as the current logged in user
netname=`ls -l /dev/console | cut -d " " -f 4`

chown -R ${netname}:Staff "/Applications/$apptoreplace"

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname
rm $dmgname.cdr

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
unset netname
exit 0

Concluding Comments

Royal TS is the only true cross-platform remote management solution available for Windows, macOS, iOS and Android. Documents created with Royal TS can be opened on all the supported platforms.

ByDan Ashley

SCRIPT | Install-Zoom-Latest

Install Zoom

Summary

These scripts will install the latest version of Zoom.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
pkgname="ZoomInstallerIT.pkg"
pkglink="https://zoom.us/client/latest/ZoomInstallerIT.pkg"
apptoupdaterunningname="zoom.us"

# Download PKG
curl -L -o "$pkgname" "$pkglink"

sleep 10

# Kill the app if it is running
killall -Kill "$apptoupdaterunningname"

# Install PKG
sudo installer -pkg $pkgname -target /

# Remove the downloaded PKG
rm $pkgname

# Clear out the used variables
unset pkgname
unset pkglink
unset apptoupdaterunningname
exit 0

Concluding Comments

Zoom these days is pretty much the most essential video conferencing tool to have access to. This script will ensure users are always installing the latest version of the application.

ByDan Ashley

SCRIPT | Install-Miro-Latest

Install Miro

Summary

These scripts will install the latest version of Miro.

Please note there is 2 versions of the script. One is for installing the arm64 version of the application intended for Macs with an Apple Silicon CPU, the other script installs the x86_64 version of the app for Macs with an Intel CPU.


Script Content (for Apple Silicon CPU Macs – arm64)

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="Miro.dmg"
dmglink="https://desktop.miro.com/platforms/darwin-arm64/Miro.dmg"
dmgmountedname="Miro"
apptoreplace="Miro.app"
apptoreplacerunningname="Miro"

# Download DMG
curl -L -O "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Copy the new version into the Applications Folder
cp -R "/Volumes/$dmgmountedname/$apptoreplace" /Applications

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
exit 0

Script Content (for Intel CPU Macs – x86_64)

#!/bin/zsh
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="Miro.dmg"
dmglink="https://desktop.miro.com/platforms/darwin/Miro.dmg"
dmgmountedname="Miro"
apptoreplace="Miro.app"
apptoreplacerunningname="Miro"

# Download DMG
curl -L -O "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Copy the new version into the Applications Folder
cp -R "/Volumes/$dmgmountedname/$apptoreplace" /Applications

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
exit 0

Concluding Comments

Miro is an online collaborative whiteboard platform that enables distributed teams to work effectively together, from brainstorming with digital sticky notes to planning and managing agile workflows.

ByDan Ashley

SCRIPT | Install-TeamViewer-Latest

Install TeamViewer

Summary

This script will install the latest version of TeamViewer.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="TeamViewer.dmg"
dmglink="https://download.teamviewer.com/download/TeamViewer.dmg"
dmgmountedname="TeamViewer"
pkgname="Install TeamViewer.app/contents/Resources/Install TeamViewer.pkg"
apptoreplace="TeamViewer.app"
apptoreplacerunningname="TeamViewer"

# Download DMG
curl -L -O "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"

# Install the new version by running the .pkg file
installer -pkg "/Volumes/$dmgmountedname/$pkgname" -target /

# Set the user as the current logged in user
netname=`ls -l /dev/console | cut -d " " -f 4`

chown -R ${netname}:Staff "/Applications/$apptoreplace"

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
unset netname
unset pkgname
exit 0

Concluding Comments

TeamViewer is an essential tool when it comes to remote IT management and support, therefore it is essential to ensure the latest version is always installed to ensure the best usage experience. This script installs latest version.

ByDan Ashley

SCRIPT | Install-Spotify-Latest

Install Spotify

Summary

This script will install the latest version of Spotify.


Script Content

#!/bin/bash
cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
dmgname="Spotify.dmg"
dmglink="https://download.scdn.co/Spotify.dmg"
dmgmountedname="Spotify"
apptoreplace="Spotify.app"
apptoreplacerunningname="Spotify"

# Download DMG
curl -L -o $dmgname "$dmglink"

# Mount DMG 
hdiutil mount -nobrowse $dmgname

# Kill the app if it is running
killall -Kill "$apptoreplacerunningname"

# Set the user as the current logged in user
netname=`ls -l /dev/console | cut -d " " -f 4`

# Remove the app from the Applications Folder
rm -rf "/Applications/$apptoreplace"
rm -rf "/Users/${netname}/Applications/$apptoreplace"
rm -rf "/Applications/Spotify (old).app"

# Copy the new version into the Applications Folder
cp -R "/Volumes/$dmgmountedname/$apptoreplace" /Applications

chown -R ${netname}:Staff "/Applications/$apptoreplace"

sudo xattr -rc "/Applications/$apptoreplace/"

# Unmount the DMG
hdiutil unmount "/Volumes/$dmgmountedname"

# Remove the downloaded DMG
rm $dmgname

# Clear out the used variables
unset dmgname
unset dmglink
unset dmgmountedname
unset apptoreplace
unset apptoreplacerunningname
unset netname
exit 0

Concluding Comments

This script installs the latest version of the Spotify application… one of the worlds most popular music streaming services.