Set corporate background and Lockscreen for all Windows machines Using PowerShell (Works with all Windows Editions)

Large organizations often use desktop wallpapers to convey important information to employees. This can include company achievements, recent news, policy updates, company brand or marketing material and more, ensuring effective communication with the workforce.

You can customize the desktop background picture for all Microsoft Desktop devices in your organization.

This artical we will discuss how to set Corporate background and Lockscreen for all Windows machines.

I – Desktop background requirements

These requirements must be met for a desktop background picture:

  • Picture file format: .jpg, jpeg, or .png
  • File location: Host on a trusted secure (https) location (in our case, we will share the background image from Azure storage Account).

So if you dont have an Storage Account, you can find here step by step explanation : Create Azure Storage Account and understand the different use cases by examples | LinkedIn

II – Prepare Wallpapers :

  • You will need two wallpapers: one for the lock screen and one for the desktop wallpaper screen.
  • Both wallpapers must be in PNG, JPG, or JPEG file/format and stored in a location that is publicly accessible, in my case I will use Azure Blob storage Account, However, you can also use other locations, such as SharePoint Online, OneDrive or Dropbox, if they provide public accessibility for the wallpapers.

1 – Upload wallpapers to Azure Blob storage Account :

After accessing your storage Account, click on the container section and create a new container (you can use an existing container).

See this article to find out how to create a container:

Create Azure Storage Account and understand the different use cases by examples | LinkedIn

I’ll then upload two JPG files, one for the Background and the other for the Lockscreen.

  1. File selection: Choose the file you wish to share.
  2. Generate SAS: Click on “Generate SAS” to start creating a SAS link.
  3. Define validity: Determine the period during which the SAS link will be valid.
  4. SAS link creation: Click on “Generate SAS token and URL” to generate the link.
  5. Share URL: Copy the generated URL for use in our Intune policy.

These steps enable you to create a SAS (Shared Access Signature) link to provide secure access to a file stored, for example, in Azure Storage. The SAS link is a convenient way of sharing files without having to give full access to your storage account.

Repeat steps 1 to 4 with the second file and copy the URL into a notepad.

III – Apply Windows Background & Lockscreen :

The following two scripts are functional and tested 100% and will only need the two newly created links :

  • Backgroud link
  • Lockscreen link

You can apply the scripts through your RMM solution, through a GPO or Windows scheduled task or even through Microsoft Intune in the Scripts section.

1 – Background Script :

Here you need only to add your background link at the first line of the script:

You need to execute this script as loged-on user and not as system or administrator.

$Backgroundlink = "https://your full URL Here"


# directory to store background
$Dir = "C:\Windows\Web\Wallpaper\" 

# Background Full path
$Download = $Dir + "Company.jpg"

# Download the Background to windows directory C:\Windows\Web\Wallpaper\
Invoke-WebRequest $Backgroundlink -OutFile $Download

# Function to set Background
Function Set-WallPaper($Image) 
{
    <#
        .SYNOPSIS
        Applies a specified wallpaper to the current user's desktop
    
        .PARAMETER Image
        Provide the exact path to the image
  
        .EXAMPLE
        Set-WallPaper -Image "C:\Wallpaper\Default.jpg"
    #>
  
Add-Type -TypeDefinition @" 
using System; 
using System.Runtime.InteropServices;
  
public class Params
{ 
    [DllImport("User32.dll",CharSet=CharSet.Unicode)] 
    public static extern int SystemParametersInfo (Int32 uAction, 
                                                   Int32 uParam, 
                                                   String lpvParam, 
                                                   Int32 fuWinIni);
}
"@ 
  
    $SPI_SETDESKWALLPAPER = 0x0014
    $UpdateIniFile = 0x01
    $SendChangeEvent = 0x02
  
    $fWinIni = $UpdateIniFile -bor $SendChangeEvent
  
    $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
 
}

Set-WallPaper -Image $Download

2 – Lockscreen Script :

Here you need only to add your Lockscreen link at the first line of the script:

You need to execute this script as administrator or as system.

# This is the link for the Lockscreen file URL
$Lockscreen = "https://your full URL Here"

# Download Directory for Lockscreen image file
$DownloadDir = "C:\Background\"

# Test if directory exist, otherwise create it
if((Test-Path $DownloadDir) -eq $false)
{
    New-Item -ItemType Directory -Path $DownloadDir -erroraction SilentlyContinue | Out-Null
}

# Full path of lockscreen
$Download = $DownloadDir + "Lockscreen-01.jpg"

# Download the background
Invoke-WebRequest $Lockscreen -OutFile $Download


# Set Path for Lockscreen image
$LockscreenPath = "C:\Background\Lockscreen-01.jpg"

# Personalization registry Key
$Key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP'
if (!(Test-Path -Path $Key)) {
   New-Item -Path $Key -Force | Out-Null
}

# Set Lockscreen image
Set-ItemProperty -Path $Key -Name LockScreenImagePath -value $LockscreenPath 

Thanks

Aymen EL JAZIRI (Microsoft MVP)
Aymen EL JAZIRI (Microsoft MVP)

Hi, I’m Aymen El Jaziri , a passionate System Administrator and Microsoft MVP, with years of hands-on experience in managing and securing modern IT infrastructures.
This blog is where I share technical guides, automation scripts, product reviews, and real-world solutions that help IT professionals simplify their day-to-day work and stay ahead in a fast-evolving cloud ecosystem.
Whether you’re here to troubleshoot an issue, improve your automation game, or learn new best practices , welcome in my blog !
Let’s build a stronger, smarter IT community together.
Feel free to connect with me on LinkedIn for more content, discussions, or collaboration opportunities.

Thanks

Aymen

Articles: 154