Index
1. Set desktop background with Intune, but allow modification
2. Push the desktop background from Intune
Set desktop background with Intune, but allow modification
It’s possible to set the desktop background with Intune, very easily. The problem however is let the user changing it afterwards which is not possible. When pushing the desktop background with Intune, changing the background image is greyed out:
The solution is to delete the regkey that is responsible for “locking” the background. Just remove this key, it doesn’t actually remove the background but only removes the lock. Relevant regkey:
1 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP\DesktopImagePath
Just remove the property “DesktopImagePath” (create a back-up first of course). If you want to do this for multiple users, you can use this PowerShell script:
1
2
3
4
5
6
7
8
9 $path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$PCSP = Get-ItemProperty $path -Name "DesktopImagePath" -ErrorAction SilentlyContinue
if (!$null -eq $PCSP) {
Remove-ItemProperty -Path $path -Name "DesktopImagePath" -Force
}
}
if ($false -eq (Test-Path "$env:ProgramData\Microsoft\AllowBackgroundPersonalization")) {
$scriptfile = New-Item -ItemType Directory -Path "$env:ProgramData\Microsoft\AllowBackgroundPersonalization"
}
If you use the Intune “Scripts” option, it’s possible that the script runs earlier than the desktop background is pushed. Since the scripts runs only once, this script doesn’t have any effect. You could create a scheduled task that runs at every logon to work around the problem:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 $script = {
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$PCSP = Get-ItemProperty $path -Name "DesktopImagePath" -ErrorAction SilentlyContinue
if (!$null -eq $PCSP) {
Remove-ItemProperty -Path $path -Name "DesktopImagePath" -Force
}
}
if ($false -eq (Test-Path "$env:ProgramData\Microsoft\AllowBackgroundPersonalization")) {
$scriptfile = New-Item -ItemType Directory -Path "$env:ProgramData\Microsoft\AllowBackgroundPersonalization"
}
$script | Out-File -FilePath "$scriptfile\AllowBackgroundPersonalization.ps1"
$schtaskName = "AllowBackgroundPersonalization"
$schtaskDescription = "Allow changing the background in Intune"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$principal = New-ScheduledTaskPrincipal "NT AUTHORITY\SYSTEM" -RunLevel Highest
$action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-File $scriptfile\AllowBackgroundPersonalization.ps1"
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
$null=Register-ScheduledTask -TaskName $schtaskName -Trigger $trigger -Action $action -Principal $principal -Settings $settings -Description $schtaskDescription -Force
Start-ScheduledTask -TaskName $schtaskName
Next step is to push the script by Intune. Since the script is running in system context and getting the regkey from the local system, you can run it in system context:
Push the desktop background from Intune
This is how you push the desktop background by Intune. Go to: https://endpoint.microsoft.com/ Create a new profile:
Fill in an internet-accessible URL:
Erjen,
Hi. Is there a way to create an exe file that would copy the corporate wallpaper and remove the windows img0.jpg and replace it with the corporate wallpaper inside the exe? I’m thinking 7zip might be able to do that. Here’s what I currently have in mind in the exe file: folder container the corporate wallpaper batch with the following commands: akeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.* icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant Administrators:(F) icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant Administrators:(F) del c:\windows\WEB\wallpaper\Windows\img0.jpg del /q C:\Windows\Web\4K\Wallpaper\Windows\*.* copy “%~dp0img0.jpg” c:\windows\WEB\wallpaper\Windows\img0.jpg copy “%~dp04k\*.*” C:\Windows\Web\4K\Wallpaper\Windows Is that doable or more practical for oobe machine?
Hello Lawrence,
I didn’t try that before but if you can find a way with PowerShell to achieve the same, I would suggest you push the PowerShell script directly from within Intune and run in system context. You should host the corporate image somewhere centrally and download it first with PowerShell. Then start replacement
Hi
I’m trying to run the PowerShell script but I get the error:
error> + }
error> + ~
error> Unexpected token ‘}’ in expression or statement.
error> + CategoryInfo : ParserError: (:) [], ParseException
error> + FullyQualifiedErrorId : UnexpectedToken
error>
Is there a syntax error here?
Hi Robin,
I checked the brackets but there seems no problem. On which Powershell version do you test the script? And does it give you the line number with the problem?
Thanks for the article Erjen…one question why do you create this folder with the script:
env:ProgramData\Microsoft\AllowBackgroundPersonalization
Also for the above post this is the error, at line 6 there is an extra bracket above the second ‘if’ statement. – I removed it and it seem to work (PowerShell ISE) :
At line:6 char:1
+ }
+ ~
Unexpected token ‘}’ in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Hi Mr T,
You’re welcome.
That folder is just for saving the .ps1 file to logical folder which can be reached by the system user (as you don’t run the script in user context).
The closing bracket is supposed to be there. Bracket on line 6 is closing the if-statement, bracket on line 7 is closing the script. You should run this script as a whole or try to run lines 1-11.
Hey great idea, but none of the scripts above work for me, the reg key still persists.
Hi Chris, do you get a result when you execute this command?
$path = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP”
Get-ItemProperty $path -Name “DesktopImagePath”
And what happens if you execute this command?
$path = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP”
Remove-ItemProperty -Path $path -Name “DesktopImagePath” -Force
Thanks for posting this, but something doesn’t seem to be working – test devices still can’t update the wallpaper.
Hi,
Thanks! This works almost 100%. The only issue is that the wallpaper sets to Black-collor after the user change the wallpaper AND restarts the computer. I want to ceep the users cahnges. Whats should i do and why dose it not ceep theusers changes?
Best Regards