question

JamesHeath-8472 avatar image
0 Votes"
JamesHeath-8472 asked balktl answered

Deploy custom background to Microsoft Teams via Intune PowerShell scripts

Hi,

I have been asked by my company to find a way to deploy corporate Backgrounds to Microsoft Teams.

I found many sites that pushed me towards using Win32 Apps within Intune and the step-by-step guides where easy to follow. However, ever guide/forum I used ended up failing saying that the status was "Not Applicable". There was NO information on why it was failing, how to diagnose the status issue or how get the app to successfully deploy.

After a many hours I contacted Microsoft Help & Support, that suggested Win32 Apps may not be the best approach and may not work as Win32 apps was primarily designed to run / execute "EXE" files wrapped in a "INTUNEWIN" file. and not run .CMD or .BAT files that were attempting to update information under "USER context"

So, Microsoft Support suggested using PowerShell scripts, located under the devices section, also suggested downloading the images from a public holding site. (like your corporate website or an azure blob)

So after some thinking and trialling various different scripts, I found a method that worked perfectly for me. I'm going to post the script I used so that other users can trial it out for themselves.

This script only seemed to work for me if I took a 2 step approach....
Firstly, download the images from a public holding site onto the users root drive (anywhere other than the %Appdata%). Then after that, the script was able to move the images from the temporary root directory to the individuals users profile...

For Example:
"C:\Users*USERNAME*\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads"
or
%AppData%\Microsoft\Teams\Backgrounds\Uploads


Script

<#
.Notes
===========================================================================
Created with: PowerShell
Created on: 20-03-2021
Created by: James Heath
Filename: Add_Custom_backgrounds_for_Teams.ps1
===========================================================================
.Description
This script will add custom backgrounds for Teams


Set Temp Folder
$TempFolder="c:\temp"

Create Temp folder if not exists
if(!(Test-Path -path $TempFolder))
{
New-Item -ItemType directory -Path $TempFolder
Write-Host "Folder has been created successfully"
}
else
{
Write-Host "The folder already exists";
}

Set Uploads Folder
$UploadFolder="$env:APPDATA\Microsoft\Templates"

Create Uploads folder if not exists
if(!(Test-Path -path $UploadFolder))
{
New-Item -ItemType directory -Path $UploadFolder
Write-Host "Folder has been created successfully"
}
else
{
Write-Host "The folder already exists";
}

Set location of images to download
$source = "https://www.COMPANY-NAME.COM/Teams_Background_1.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_2.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_3.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_4.jpg";

Start download of image to temp folder
Start-BitsTransfer -Source $source -Destination $TempFolder, #$TempFolder, $TempFolder, $TempFolder

Copy images from temp location "c:\temp\" to "Users" Microsoft Teams custom backgrounds location ("\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads")
$AllLocalUsers = (Get-ChildItem -path $env:SystemDrive:\Users).name
$AllLocalUsers += "Default"
foreach($user in $AllLocalUsers)
{

$destination = ("$env:SystemDrive" + "\users\" + "$user" + "\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads")
if(!(Test-Path -Path $destination))
{
New-Item -Path "$destination" -ItemType Directory | out-null
}
copy-item -path "$TempFolder*.*" -Destination $destination -Force

}

Tidy up duplicate images by removing the temp folder
Remove-Item -Path $TempFolder -Recurse -Force


Script-End


I hope this helps many users to push custom backgrounds to Microsoft teams via the help of Intune PowerShell scripts

windows-server-powershell
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for sharing your solution. It will be helpful to other community members who have similar questions.

0 Votes 0 ·

1 Answer

balktl avatar image
0 Votes"
balktl answered

At some point this feature changed, so a big GOTYA to watch out for when moving backgrounds into the Upload folder...

In order for a background to show up - you need a pair of images for the background to show up in the background selection panel.

So if the background was named Foo.png, I would also need a Foo_thumb.png to exist in the folder as well. Teams will place the custom background in the selection panel as expected.

The script above would change one line to this:
$source = "https://www.COMPANY-NAME.COM/Teams_Background_1.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_1_thumb.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_2.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_2_thumb.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_3.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_3_thumb.jpg";, "https://www.COMPANY-NAME.COM/Teams_Background_4.jpg"; "https://www.COMPANY-NAME.COM/Teams_Background_4_thumb.jpg";,

Quick tip for this: to generate the thumb - use the Add-New button in the backgrounds panel and then grab the "_thumb" file from your %APPDATA%\Microsoft\Teams\Backgrounds\Upload folder.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.