Install custom MS Teams background images

LaMantia
New Contributor III

Hi all, I did not see anything like what I needed so I created one. Below is a script to copy image files to a users local directory. It works fine, very basic, but I'd like to combine the two if statements and work out an exit code if the source files are not present. If anyone is bored out there???? : )

#!/bin/sh

#Created by Brian LaMantia 6/1/2020
#Move FIS background images from /private/tmp to the current users Uploads folder in Teams. 
#Run after the images are deployed to the tmp folder then displays a message to the user. 
#If the package fails, do not display a message. 
#If you make this better, post a copy for me!  

#get current user
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

#Check if the images package was installed
sourceFiles=/private/tmp/Teams

#Check if Teams uploads folder exists
teamsPath=/Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads/

#jamfhelper path
jamfHelper=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper

#set icon
icon=/Applications/Microsoft Teams.app/Contents/Resources/icon.icns

if  [ ! -d "$sourceFiles" ]; then
    echo "Missing source files, script will fail, did not display messsage."
else
    #Tell the user that the backgrounds are available.
    "$jamfHelper" -windowType hud -windowPosition ul -title "Your title here" -heading "Microsoft Teams" -description "Check it out! New Teams video backgrounds are available now. We hope you enjoy them!" -icon "$icon" -button1 "OK" &
fi

#if teamsPath exists copy background images to the Uploads folder and set permissions, else quit
if  [ -d "$teamsPath" ]; then
    cp /private/tmp/Teams/*.* /Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads
    chown "$currentUser":wheel /Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads/*.*
else
    echo "Path is missing, creating required folders"
    mkdir -p /Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads
    cp /private/tmp/Teams/*.* /Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads
    chown "$currentUser":wheel /Users/"$currentUser"/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads/*.*
fi
9 REPLIES 9

garybidwell
Contributor III

I do this a different way without the need of a script.
I just create a DMG using composer of the Teams background images in the required path location and just use Jamf's FEU & FUT package feature in policies to deploy straight in to each users account.

LaMantia
New Contributor III

@garybidwell Thank you. I've never used that option. I will test that out for sure. Any "gotchas" with using FUE & FUT?

garybidwell
Contributor III

not really, its pretty simple to use as long as you remember it only works on DMG and not PKG. I like to set the permissions within Composer myself just as force of habit making PKG's all the time, but with the DMG FUE & FUT options it make it irrelevant as Jamf does all this automatically as part of the install process.
You just need to set your deployment frequency to "Once per user per computer" to ensure it deploys to every user account on every device.

savriette
New Contributor

How does JAMF know where to put the image for FUE/FUT? Microsoft kind of buried it in /Users/username/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads? I could see doing that for a standard wallpaper, but I'm just not understanding how the FUE/FUT function works.

andrew_nicholas
Valued Contributor

The path dropped into composer essentially becomes a static variable for everything after "/Library/Application Support/Microsoft/Teams/Backgrounds/Uploads". Everything before that is then a blank value that is just iteratively filled in when rolling through user account or language templates and permissions updated accordingly.

vanschip-gerard
Contributor

I copied your extact script but here this

Script result: /Library/Application Support/JAMF/tmp/Teams background: line 16: Support/Microsoft/Teams/Backgrounds/Uploads/: No such file or directory
/Library/Application Support/JAMF/tmp/Teams background: line 19: Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper: No such file or directory /Library/Application Support/JAMF/tmp/Teams background: line 22: Teams.app/Contents/Resources/icon.icns: No such file or directory Path is missing, creating required folders /Library/Application Support/JAMF/tmp/Teams background: line 28: : command not found mkdir: Support: Read-only file system cp: Support/Microsoft/Teams/Backgrounds/Uploads is not a directory chown: Support/Microsoft/Teams/Backgrounds/Uploads/*.*: No such file or directory

LaMantia
New Contributor III

Hi All that script stopped working for us. Instead of repairing it, we moved to a package and use Jamf's FEU & FUT option. 

Lokeshm
New Contributor II

I followed below process and it worked for me-

- Uploaded Teams PNG file in /Private/Temp

- Drag that location to Jamf Composer

- Create PostInstall script as below -

#get current user
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

#Check if the images package was installed
sourceFiles=/private/tmp/Teams

#Check if Teams background & uploads folder exists
teamsPath=/Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads/

#jamfhelper path
jamfHelper=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper

#set icon
#icon=/Applications/Microsoft Teams.app/Contents/Resources/icon.icns

if [ ! -d "$sourceFiles" ]; then
echo "Missing source files, script will fail, did not display messsage."
else
#Tell the user that the backgrounds are available.
"$jamfHelper" -windowType hud -windowPosition ul -title "Your title here" -heading "Microsoft Teams" -description "Check it out! New Teams video backgrounds are available now. We hope you enjoy them!" -icon "$icon" -button1 "OK" &
fi

#if teamsPath exists copy background images to the Uploads folder and set permissions, else quit
if [ -d "$teamsPath" ]; then
cp /private/tmp/Teams/*.* /Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads
chown "$currentUser":wheel /Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads/*.*
else
echo "Path is missing, creating required folders"
mkdir -p /Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads
cp /private/tmp/Teams/*.* /Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads
chown "$currentUser":wheel /Users/"$currentUser"/Library/Application\ Support/Microsoft/Teams/Backgrounds/Uploads/*.*
fi

 

- Build as PKG

-Upload in Jamf and it works. No need of FEU and FTU

 

Hope it helps

Rid1
New Contributor

I followed the same thing, however with the new teams client this needs to change a little here is my sample script 

#!/bin/bash

# Created by Brian LaMantia 6/1/2020
# Move FIS background images from /private/tmp to the current user's Uploads folder in Teams.
# Run after the images are deployed to the tmp folder then displays a message to the user.
# If the package fails, do not display a message.
# If you make this better, post a copy for me!

# get current user
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

# Check if the images package was installed
sourceFiles="/private/tmp/Teams backgrounds"

# Check if Teams uploads folder exists
teamsPath="/Users/$currentUser/Library/Containers/com.microsoft.teams2/Data/Library/Application Support/Microsoft/MSTeams/Backgrounds/Uploads"

# jamfhelper path
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

# set icon
# icon="/Applications/Microsoft Teams.app/Contents/Resources/icon.icns"

if [ ! -d "$sourceFiles" ]; then
echo "Missing source files, script will fail, did not display message."
else
# Tell the user that the backgrounds are available.
"$jamfHelper" -windowType hud -windowPosition ul -title "Teams Backgrounds Updated" -heading "Microsoft Teams" -description "Check it out! New Teams video backgrounds are available now. We hope you enjoy them!" -icon "$icon" -button1 "OK" &
fi

# If teamsPath exists, copy background images to the Uploads folder and set permissions, else quit
if [ -d "$teamsPath" ]; then
cp /private/tmp/Teams\ backgrounds/*.* "$teamsPath"
chown "$currentUser":wheel "$teamsPath"/*.*
else
echo "Path is missing, creating required folders"
mkdir -p "$teamsPath"
cp /private/tmp/Teams\ backgrounds/*.* "$teamsPath"
chown "$currentUser":wheel "$teamsPath"/*.*
fi

exit 0 ## Success
exit 1 ## Failure