Set-Wallpaper Powershell Function

The following Powershell function will change the current user’s desktop wallpaper automatically using the SystemParametersInfo function that can be located in the User32.dll.

Function Set-WallPaper($Image) {
Applies a specified wallpaper to the current user's desktop
Provide the exact path to the image

Set-WallPaper -Image "C:\Wallpaper\Default.jpg"


Add-Type -TypeDefinition @" 
using System; 
using System.Runtime.InteropServices;

public class Params
    public static extern int SystemParametersInfo (Int32 uAction, 
                                                   Int32 uParam, 
                                                   String lpvParam, 
                                                   Int32 fuWinIni);

$UpdateIniFile = 0x01
$SendChangeEvent = 0x02

$fWinIni = $UpdateIniFile -bor $SendChangeEvent 

$ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)

Set-WallPaper -Image “C:\Wallpaper\Default.jpg”

For more information about the SystemParametersInfo function, please see this link to MSDN.


  1. hello to start with i say i don’t know english i write google translate
    I need help in the script is about enabling streaming in windows 10

  2. how to execute the script?

    • Jose Espitia

      Ernesto, just copy the function in ISE and run the function.
      Set-WallPaper -Image "C:\Wallpaper\Default.jpg"

  3. forget about it

  4. Perfect !

    Finally a script that works reliably on Windows 10 !

    Many BIG THANKS !

Leave a Reply