Site feedback

JamesHeath-8472 avatar image
0 Votes"
JamesHeath-8472 Posted ·

Deploy custom/corporate background(s) 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 "INUNEWIN" 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

qna-feedback
· 1
10 |1000 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.

@JamesHeath-8472 , thank you for the feedback. This area is specifically for Microsoft Q&A feedback only, due to this, we are closing this item. But we appreciate your support for other users, if possible, try finding a better area of the site to post this helpful information in, as this is for feedback only.

0 Votes 0 ·

No Solutions

Your Opinion Counts

Share your feedback, or help out by voting for other people's feedback.