top of page
Search

(195) Microsoft Intune - Set Lockscreen and Desktop Wallpaper for Shared Devices

  • Writer: Mr B SOE way
    Mr B SOE way
  • 7 days ago
  • 3 min read

Standard wallpaper and lock screen customization via Intune is technically restricted to Windows Enterprise editions. If you’re on Microsoft 365 Business Premium, the Settings Catalog won't work for this.

However, you can bypass this limitation by deploying a Win32 package. Not only does this solve the licensing hurdle, but it also simplifies deployment since the image file is bundled right into the package rather than hosted online.

Prepare the following:

  • wallpaper.jpg is the downloaded image that should appear on device’s lockscreens and desktop backgrounds. If you want a different image, then add another .jpg and update the $WallpaperIMG and $LockscreenIMG according.

  • Install.ps1

  • Uninstall.ps1

  • Detect.ps1


Install.ps1:


If you want a different image, then add another .jpg and update the $WallpaperIMG and $LockscreenIMG according.

$PackageName = "Wallpaper"
$Version = 1

# Set image file names for desktop background and lock screen
# leave blank if you wish not to set either of one
$WallpaperIMG = "wallpaper.jpg"
$LockscreenIMG = "wallpaper.jpg"

Start-Transcript -Path "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\$PackageName-install.log" -Force
$ErrorActionPreference = "Stop"

# Set variables for registry key path and names of registry values to be modified
$RegKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$DesktopPath = "DesktopImagePath"
$DesktopStatus = "DesktopImageStatus"
$DesktopUrl = "DesktopImageUrl"
$LockScreenPath = "LockScreenImagePath"
$LockScreenStatus = "LockScreenImageStatus"
$LockScreenUrl = "LockScreenImageUrl"
$StatusValue = "1"

# local path of images
$WallpaperLocalIMG = "C:\Windows\System32\Desktop.jpg"
$LockscreenLocalIMG = "C:\Windows\System32\Lockscreen.jpg"

# Check whether both image file variables have values, output warning message and exit if either is missing
if (!$LockscreenIMG -and !$WallpaperIMG){
    Write-Warning "Either LockscreenIMG or WallpaperIMG must has a value."
}
else{
    # Check whether registry key path exists, create it if it does not
    if(!(Test-Path $RegKeyPath)){
        Write-Host "Creating registry path: $($RegKeyPath)."
        New-Item -Path $RegKeyPath -Force
    }
    if ($LockscreenIMG){
        Write-Host "Copy lockscreen ""$($LockscreenIMG)"" to ""$($LockscreenLocalIMG)"""
        Copy-Item ".\$LockscreenIMG" $LockscreenLocalIMG -Force
        Write-Host "Creating regkeys for lockscreen"
        New-ItemProperty -Path $RegKeyPath -Name $LockScreenStatus -Value $StatusValue -PropertyType DWORD -Force
        New-ItemProperty -Path $RegKeyPath -Name $LockScreenPath -Value $LockscreenLocalIMG -PropertyType STRING -Force
        New-ItemProperty -Path $RegKeyPath -Name $LockScreenUrl -Value $LockscreenLocalIMG -PropertyType STRING -Force
    }
    if ($WallpaperIMG){
        Write-Host "Copy wallpaper ""$($WallpaperIMG)"" to ""$($WallpaperLocalIMG)"""
        Copy-Item ".\$WallpaperIMG" $WallpaperLocalIMG -Force
        Write-Host "Creating regkeys for wallpaper"
        New-ItemProperty -Path $RegKeyPath -Name $DesktopStatus -Value $StatusValue -PropertyType DWORD -Force
        New-ItemProperty -Path $RegKeyPath -Name $DesktopPath -Value $WallpaperLocalIMG -PropertyType STRING -Force
        New-ItemProperty -Path $RegKeyPath -Name $DesktopUrl -Value $WallpaperLocalIMG -PropertyType STRING -Force
    }  
}


New-Item -Path "C:\ProgramData\MrBSoeWay\Validation\$PackageName" -ItemType "file" -Force -Value $Version

Stop-Transcript

If you have made changes to the $WallpaperIMG and $LockscreenIMG, adjust accordingly.


$PackageName = "Wallpaper"

# Set image file names for desktop background and lock screen
# leave blank if you with not to set either of one
$WallpaperIMG = "wallpaper.jpg"
$LockscreenIMG = "wallpaper.jpg"

Start-Transcript -Path "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\$PackageName-uninstall.log" -Force
$ErrorActionPreference = "Stop"

# Set variables for registry key path and names of registry values to be modified
$RegKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$DesktopPath = "DesktopImagePath"
$DesktopStatus = "DesktopImageStatus"
$DesktopUrl = "DesktopImageUrl"
$LockScreenPath = "LockScreenImagePath"
$LockScreenStatus = "LockScreenImageStatus"
$LockScreenUrl = "LockScreenImageUrl"

# Check whether both image file variables have values, output warning message and exit if either is missing
if (!$LockscreenIMG -and !$WallpaperIMG){
    Write-Warning "Either LockscreenIMG or WallpaperIMG must has a value."
}
else{
    # Check whether registry key path exists, create it if it does not
    if(!(Test-Path $RegKeyPath)){
        Write-Warning "The path ""$RegKeyPath"" does not exists. Therefore no wallpaper or lockscreen is set by this package."
    }
    if ($LockscreenIMG){
        Write-Host "Deleting regkeys for lockscreen"
        Remove-ItemProperty -Path $RegKeyPath -Name $LockScreenStatus -Force
        Remove-ItemProperty -Path $RegKeyPath -Name $LockScreenPath -Force
        Remove-ItemProperty -Path $RegKeyPath -Name $LockScreenUrl -Force
    }
    if ($WallpaperIMG){
        Write-Host "Deleting regkeys for wallpaper"
        Remove-ItemProperty -Path $RegKeyPath -Name $DesktopStatus -Force
        Remove-ItemProperty -Path $RegKeyPath -Name $DesktopPath -Force
        Remove-ItemProperty -Path $RegKeyPath -Name $DesktopUrl -Force
    }  
}

Write-Host "Deleting Validation file."
Remove-Item -Path "C:\ProgramData\MrBSOEWay\Validation\$PackageName" -Force

Stop-Transcript
$PackageName = "Wallpaper"
$Version = 1

$ProgramVersion_current = Get-Content -Path "C:\ProgramData\MrBSOEWay\Validation\$PackageName" 

if($ProgramVersion_current -eq $Version){
    Write-Host "Found it!"
}

Once the app is packaged and deployed, you will get this on end user's devices.

Login screen:




 
 
 

Comments


bottom of page