Share via


set wallpaper GPO using powershell

Question

Sunday, February 16, 2014 11:29 PM

I'm trying to set a default wallpaper for a users OU by scripting with powershell
I came up with the next script:

1/   Import-Module grouppolicy
2/   new-gpo -Name WP_ICT| new-gplink -target "ou=All_ICT,dc=LUMO,dc=local"
3/   Set-ItemProperty "HKCU:\Control Panel\Desktop\ -Name "Wallpaper" -value "H:\xxBackground\ICT.jpg"
4/   rundll32.exe user32.dll, UpdatePerUserSystemParameters

It didn't quite do the trick...
Wat it did was setting the background of my server to the .jpg i want to use for the users OU.

When i placed another pipeline after line 2 (new-gplink) the script runs but then asked for a guid.

Can someone help me please?

All replies (2)

Tuesday, February 18, 2014 3:31 AM ✅Answered

Hi,

We should use Set-GPRegistryValue command instead of Set-ItemProperty:

Set-GPRegistryValue -Name "WP_ICT" -key "HKCU:\Control Panel\Desktop\ -ValueName "Wallpaper" -type string -value "H:\xxBackground\ICT.jpg"

More details about how to use Powershell to set group policy registry based settings, please check below two links:

Set-GPRegistryValue

http://technet.microsoft.com/en-us/library/ee461034.aspx

Set-GPPrefRegistryValue

http://technet.microsoft.com/en-us/library/ee461036.aspx

Hope this helps.

Regards,

Yan Li

Regards, Yan Li


Tuesday, February 18, 2014 1:26 PM ✅Answered

1/ Import-Module grouppolicy
2/ New-GPO -Name WP_ICT | New-GPLink -Target "OU=All_ICT, DC=LUMO, DC=local"
3/ Set-GPPrefRegistryValue -Name WP_ICT -Context User -Action Replace -Key "HKCU\Control Panel\Desktop" -ValueName Wallpaper -Value "\ServerLUMO\xxBackground_share\ICT.jpg" -Type String

It does the trick....