Category Archives: Script Repository

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“.


Script Content

#!/bin/zsh

islaptop=`/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"`

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

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 "$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.

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.

SCRIPT | Install-Zoom-Latest

Install Zoom

Summary

These scripts will install the latest version of Zoom.


Script Content

#!/bin/zsh
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.

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/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-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.

SCRIPT | Install-TeamViewer-Latest

Install TeamViewer

Summary

This script will install the latest version of TeamViewer.


Script Content

#!/bin/zsh
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.

SCRIPT | Install-Spotify-Latest

Install Spotify

Summary

This script will install the latest version of Spotify.


Script Content

#!/bin/zsh
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.

SCRIPT | Install-Skype-Latest

Install Microsoft Skype

Summary

This script will install the latest version of Microsoft Skype.


Script Content

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

# Update variables. These shouldn't need to change for each update
dmgname="getskype-macosx.dmg"
dmglink="http://www.skype.com/go/getskype-macosx.dmg"
dmgmountedname="Skype"
apptoreplace="Skype.app"
apptoreplacerunningname="Skype"

# 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

# 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
exit 0

Concluding Comments

Microsoft Teams is essential communication tool for many users, this script allows you to know the latest version is always being deployed.

SCRIPT | Install-Keka-Latest

Install Keka

Summary

This script will install the latest version of Keka.


Script Content

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

# Update variables. These shouldn't need to change for each update
dmgname="Keka.dmg"
#dmglink="http://download.kekaosx.com/"
dmglink="https://d.keka.io/"
dmgmountedname="Keka"
apptoreplace="Keka.app"
apptoreplacerunningname="Keka"

# Download DMG
curl -L -o $dmgname "$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

# 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
sudo 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 will install the latest version of the Keka application for compressing and extracting files.

SCRIPT | Install-Google-Drive-Latest

Install Google Drive

Summary

This script will install the latest version of the Google Drive desktop application.


Script Content

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

# Update variables. These shouldn't need to change for each update
dmgname="googledrive.dmg"
dmglink="https://dl.google.com/drive-file-stream/googledrive.dmg"
dmgmountedname="Install Google Drive"
pkgname="GoogleDrive.pkg"
apptoreplace="Google Drive.app"
apptoreplacerunningname="Google Drive"

# 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 /

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

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

# User-enabled browser authentication for Google Drive
sudo -s -u $netname defaults write com.google.drivefs.settings ForceBrowserAuth -bool true

# 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 accounttype
unset pkgname
exit 0

Concluding Comments

The Google Drive desktop application makes sync’ing Google Drive contents to and from your Mac easier than ever.

SCRIPT | Install-Firefox-Latest

Install Firefox

Summary

This script will install the latest version of Firefox.


Script Content

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

# Update variables. These shouldn't need to change for each update
dmgname="Firefox.dmg"
dmglink="http://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US"
dmgmountedname="Firefox"
apptoreplace="Firefox.app"
apptoreplacerunningname="Firefox"

# Download DMG
curl -L -o $dmgname "$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

# 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
exit 0

Concluding Comments

Firefox is a common web browser often used as an alternative to either Google Chrome of Safari for macOS users. This script allows you to know the latest version is always being deployed.