Skip to content

Instantly share code, notes, and snippets.

@azurekid
Last active April 16, 2020 14:03
Show Gist options
  • Save azurekid/197473abc09280ae5c3a603719e83ead to your computer and use it in GitHub Desktop.
Save azurekid/197473abc09280ae5c3a603719e83ead to your computer and use it in GitHub Desktop.
Add Bing image to Microsoft Teams backgrounds
$TeamsPath = "$($env:appdata)\Microsoft\Teams\Backgrounds\Uploads"
$web = New-Object Net.WebClient
$webclient = New-Object System.Net.WebClient
$baseUrl = "https://www.bing.com"
$jsonUrl = "https://www.bing.com/HPImageArchive.aspx?format=js&mbl=1&idx=0&n=1&cc=auto"
if (-not(Test-Path $TeamsPath)) {
New-Item -ItemType Directory -Path $TeamsPath
}
$json = Invoke-WebRequest -Uri $jsonUrl | ConvertFrom-Json
$url = $baseUrl + $json.images.url.toString().trim();
$fileName = ($json.images.urlbase).Substring(7) + ".jpg"
$ImagePath = Join-Path $TeamsPath $fileName
Write-Output "Sending Bing image to Teams backgrounds folder"
$webClient.DownloadFile($url, $ImagePath)
Write-Output "All Done!"
#Spotlight Image
$BingPath = "$($env:localappdata)\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
$TeamsPath = "$($env:appdata)\Microsoft\Teams\Backgrounds\Uploads"
$Date = Get-Date -Format "dd-MM-yyyy_HHmms"
$SpotlightImages = Get-ChildItem -Path $BingPath `
| Where-Object { $_.LastWriteTime -ge (Get-Date).AddDays(-1) }
$item = ($SpotlightImages | Sort-Object -Property Length -Descending)[0]
Write-Output "Sending Spotlight image to Teams backgrounds folder"
$item | Copy-Item -Destination "$($TeamsPath)\spotlight_$($Date).jpg"
@azurekid
Copy link
Author

azurekid commented Apr 16, 2020

Add Daily BING image to Microsoft Teams Background

If you really are a fan of the BING image of the day you can use this little script to add the image to the Microsoft Teams Background image folder.

Completely useless but still fun, just because we can.

image

image

Add Daily Windows Spotlight image to Microsoft Teams Background

You can also use the spotlight to teams script to add the Windows Spotlight image of the day to the Microsoft Teams Background image folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment