How to set Custom backgrounds for Desktop and Lockscreen in Windows 10 Creators Update v1703 and later with PowerShell

Hi Friends, this is a quick blog to show how one can set Custom backgrounds for Desktop and Lock Screen in Windows 10 Creators Update v1703 and later with PowerShell.

I am sure people have been reading about the new features that were recently introduced with the release of Windows 10 build v1703 also known as The Creators Update. The Script here uses one of those new feature additions called PersonalizationCSP that empowers IT Administrators to set custom backgrounds for the Desktop and the Lock Screen as part of their Build and Capture sequence.

# The Script sets custom background Images for the Desktop and the Lock Screen by leveraging the new feature of PersonalizationCSP that is only available in the Windows 10 v1703 aka Creators Update and later build versions #

# Note: The Image File names can be anything you wish, however the Image resolution that I have been using for my environment was 3840X2160 (not sure if that matters though) #

# Applicable only for Windows 10 v1703 and later build versions #

# Script also assumes that you have already copied over the Desktop and LockScreen Images to the C:\OEMFiles\ folder and are named as Desktop.jpg and LockScreen.jpg respectively (could vary for your environment) #
$RegKeyPath = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP”

$DesktopPath = “DesktopImagePath”
$DesktopStatus = “DesktopImageStatus”
$DesktopUrl = “DesktopImageUrl”
$LockScreenPath = “LockScreenImagePath”
$LockScreenStatus = “LockScreenImageStatus”
$LockScreenUrl = “LockScreenImageUrl”

$StatusValue = “1”
$DesktopImageValue = “C:\OEMFiles\Desktop.jpg”  #Change as per your needs
$LockScreenImageValue = “C:\OEMFiles\LockScreen.jpg”  #Change as per your needs

IF(!(Test-Path $RegKeyPath))

{

New-Item -Path $RegKeyPath -Force | Out-Null

New-ItemProperty -Path $RegKeyPath -Name $DesktopStatus -Value $StatusValue -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenStatus -Value $StatusValue -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopPath -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopUrl -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenPath -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenUrl -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null

}

ELSE {

New-ItemProperty -Path $RegKeyPath -Name $DesktopStatus -Value $Statusvalue -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenStatus -Value $value -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopPath -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopUrl -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenPath -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenUrl -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null
}

The script can also be downloaded from link below:

https://1drv.ms/t/s!AljjQEIEs7p2jWGOBHlScNgjX4-F

Cheers 🙂

6 thoughts on “How to set Custom backgrounds for Desktop and Lockscreen in Windows 10 Creators Update v1703 and later with PowerShell

  1. Braxton Davis

    Can users change the desktop wallpaper? I want to set a default wallpaper for new users but not prohibit users from changing to their own. Thanks!

    Like

  2. anonymous

    I just tried this and confirmed that it prevents the users from being able to change their desktop wallpaper. Still searching for a way to set the default AND let the users change it if they wish.

    Like

  3. artem bokovski

    Great. Finally something that works for changing the lock screen

    Like

  4. David Shortall

    Hey, this is a great script, but my users need to be able to change their own lock screen background – Is there any way to achieve this?

    Like

  5. Dylan

    Doesn’t the PersonalizationCSP only work for Windows Enterprise and Education?

    Like

  6. First of all, thank you to @ferozekhan267oa for this script. It works on my work Win10 Pro 1809.

    I like using the Bing Desktop Wallpapers.
    https://www.microsoft.com/en-sg/download/details.aspx?id=35844

    So much so that I set is as a random Lock Screen Wallpaper as well. Then I became annoyed with the startup lock screen wallpaper before login #firstworldproblems. Probably because it reminded me of the DragonGlass cave #Season8doesntexist. So, upon finding this script to change that Default Lock Screen Wallpaper, I became determined to get a random pre-Login Lock Screen Wallpaper from among the Bing Wallpaper cache. So, the script below is the result:

    * Do make sure you have the “C:\OEMFiles” folder
    * Script available here
    https://1drv.ms/u/s!AqHoqhAcwfB8gqJSkxIw2OHxmogHtg

    Use this link below to attach that script to the logout process:

    https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789190(v%3Dws.11)#how-to-assign-user-logoff-scripts

    Again, thank you @ferozekhan267oa

    – – –
    @Sryn

    Like

Leave a comment