Logon PowerShell script to set corporate wallpaper for different resolutions

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Abdul Gafoor Abdul Gafoor 5 months, 2 weeks ago.

  • Author
    Posts
  • #63478
    Profile photo of Abdul Gafoor
    Abdul Gafoor
    Participant

    Hi All,

    I would like to get help here on setting corporate wallpaper through GPO. Following are the requirement.

    • We do have different sized images for corporate wallpaper, which needs to set for different resolution.
    • Most users are having dual monitors. Correctly sized wallpaper needs to be set for both monitors.
    • All clients are running Windows 7 and servers are running Windows 2012 R2, which means PowerShell scripts can be set as logon script.

    Thank you 🙂

  • #63480
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    What kind of help do you need? If you search Google for the keywords powershell set desktop wallpaper you will get lots of examples including polished scripts.

  • #63481
    Profile photo of Abdul Gafoor
    Abdul Gafoor
    Participant

    I did Daniel, but I didn't find one matching my requirements. Or, I might not have found one yet. Can you help me find a polished script please?

  • #63495
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    I think you won't find a script which exactly fits "your" requirements. You'll need to use different examples from the web and combine them for your use case.

    I can help you a little bit with finding and providing examples, but writing the script for you would be too much of an ask. You could use freelancers on "upwork.com", "codementor.io" or "handhands.com" to get the job done.

    What are the actual pixel resolutions of the corporate wallpapers like 1920×1080? Please provide a list of the pixel resolutions.

    Thanks,
    Daniel

  • #63553
    Profile photo of Abdul Gafoor
    Abdul Gafoor
    Participant

    My bad David. I wasn't asking for complete code. Sorry that the question gave such an impression. I am pasting the code I have so far, which seems to apply only on primary monitor. I need help only applying wallpaper on additional monitors as well. Most users are having dual monitors and couple of users are having 4 monitors as well.

    $sourcefolder = "\\domain.com\NETLOGON\Wallpapers"
    $targetfolder = $env:SystemRoot
    $desktops = Get-WmiObject -Class Win32_DesktopMonitor | Where-Object { $_.Availability -eq "3" }
    
    foreach ($desktop in $desktops)
    {
        # Generate wallpaper file name and path
    	$wp = "Wallpaper_$($desktop.ScreenWidth)x$($desktop.ScreenHeight).jpg"
        $wppath = "$($sourcefolder)\$($wp)"
    
        if (Test-Path -LiteralPath $wppath)
        {
            # Copy walpaper file
            robocopy $sourcefolder $targetfolder $wp /NFL /NDL /NJH /NJS
    
            # Set wallpaper for the current user
            Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" `
                    -Name "WallPaper" -Value "$($targetfolder)\$($wp)"
            rundll32.exe user32.dll, UpdatePerUserSystemParameters
        }
    }

You must be logged in to reply to this topic.