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