QuickPost – setting an “Image of the day” desktop background

I like to try and make my desktop images look as nice as possible, with a minimum of fuss. Doubtless this is something many of you have done already, in many different ways, so I am just quickly documenting this for my own reference.

There are stacks of ways you can change desktop backgrounds or other branding mechanisms – Windows spotlight, Windows Themes, apps, scripts, etc. I find using Themes to be a particular pain and putting third-party apps in the image doesn’t always fly – and even the Windows Store apps that handle this kind of thing are useless because they’re installed on a user-by-user basis. I also don’t want to manage my own library of images – I’d rather just pull something from an online source and run with it.

So I simply use a combination of a Scheduled Task running some PowerShell and a GPO to cycle my desktop background across my images once a day.

Firstly you need to set up a GPO that points to a specific wallpaper – ideally local so you don’t worry about loss of access to a file share. The GPO you need is in User Configuration | Policies | Admin Templates | Desktop | Desktop and is called “Desktop Wallpaper”.

Set the wallpaper name to the full path of your file (mine is c:\windows\web\wallpaper\james-rankin.com-wallpaper.jpg, and the wallpaper folder is as sensible a location as any). Also, choose the Wallpaper Style as part of this GPO (I find Stretch to be the best overall, but YMMV).

Additionally, I always set User Configuration | Policies | Admin Templates | Control Panel | Personalization | Prevent changing desktop background to Enabled

Next we simply need some PowerShell to grab an online image and overwrite the existing file we have chosen with our new one. I’m using Bing’s “Image of the day” for the source – you can substitute others as required, but I find the Bing collection to be pretty good for my requirements. You can change the resolution and image file name in this script as required.

$Market = "en-GB"
$Resolution = "1920x1200"
$ImageFileName = "c:\windows\web\wallpaper\james-rankin.com-wallpaper.jpg"
[xml]$Bingxml = (New-Object System.Net.WebClient).DownloadString("http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=$($Market)");
$ImageUrl = "http://www.bing.com$($Bingxml.images.image.urlBase)_$($Resolution).jpg";
Invoke-WebRequest -UseBasicParsing -Uri $ImageUrl -OutFile "$ImageFileName"

Save this file somewhere with a .ps1 extension, and then copy it down to your golden images somehow. You can bake it in, deploy it with a Group Policy Preferences Files action, put it down with third-party tooling, etc. – the choice is yours.

Once the PowerShell script is present on the machine, you can simply call it a specified time every day from a Scheduled Task. You can even set the Scheduled Task up through Group Policy as well if you desire. Set it with the following properties

Obviously, there are many parameters here you need to change to your requirements. The -File parameter in the PowerShell command line is the most pertinent, also the time of execution, recurrence rate and offset rate you will also need to set as you see fit.

Once set up, the task should run at the specified time and overwrite the existing wallpaper file with the new “image of the day”. When your users log out and back in, they will then pick up the new shiny updated wallpaper and have a nice new background to look at each day.

Tasty new backgrounds each morning

I know I’ve been promising this for a while, but….we should hopefully have some content on the abomination called Windows 11 coming soon, so stay tuned.

Loading

One comment

  1. This is great! Just enabled it on my home lab. I had previously used BGInfo to push updates to wallpapers I like, but using bing ‘image of the day” is even better. Thanks, James

Leave a Reply

Your email address will not be published. Required fields are marked *