Deploy custom background to Microsoft Teams via Intune PowerShell scripts

James Heath 1 Reputation point
2021-03-22T14:25:01.53+00:00

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:\UsersUSERNAME\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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,396 questions
{count} votes

3 answers

Sort by: Most helpful
  1. balktl 11 Reputation points
    2021-04-30T19:02:34.483+00:00

    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.

    2 people found this answer helpful.
    0 comments No comments

  2. Marek Ekinci 5 Reputation points
    2023-04-12T07:35:22.0566667+00:00

    Well had fun deleting the entire script and just making it again but it wasted to much time.
    Here is the solution fellas.

    #Set Uploads Folder
    $destination = "$env:APPDATA\Microsoft\Teams\Backgrounds\Uploads"
    #Create Uploads folder if not exists
    if(!(Test-Path -path $destination))
    {
    New-Item -ItemType directory -Path $destination
    Write-Host "Folder has been created successfully"
    }
    else
    {
    Write-Host "The folder already exists";
    }
    #Set location of images to download
    $source = "\\Contenso.de\Shares\Contenso\Backgrounds\Teams\*";
    Copy-Item -Path $source -Destination $destination
    write-host "Successful"
    #Script-End
    
    1 person found this answer helpful.
    0 comments No comments

  3. Wagner, Christian 0 Reputation points
    2024-03-25T15:31:23.14+00:00

    Hi, the folder APPDATA\Microsoft\Teams\Backgrounds\Uploads doesn't exist on my MTRs. Acutally the documentation says the files should be copied to

    C:\Users\Skype\AppData\Local\Packages\Microsoft.SkypeRoomSystem_8wekyb3d8bbwe\LocalState
    
    0 comments No comments