Skip to content

Instantly share code, notes, and snippets.

@milk-truck
Created August 12, 2022 14:58
Show Gist options
  • Save milk-truck/412240307b8efd69ca0634bc14de8d2e to your computer and use it in GitHub Desktop.
Save milk-truck/412240307b8efd69ca0634bc14de8d2e to your computer and use it in GitHub Desktop.
#-------------------------------------------------------------------#
# ScriptName : SetWall.ps1 #
# Description : Force a Desktop wallpaper Refresh #
# Credits : Unknown (if you know original creator, let us know) #
# #
# Date : 01 July 2020 #
#-------------------------------------------------------------------#
#Modify Path to the picture accordingly to reflect your infrastructure
$imgPath="\\Domain.lab\netlogon\Wallpaper.png"
$code = @'
using System.Runtime.InteropServices;
namespace Win32{
public class Wallpaper{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public static void SetWallpaper(string thePath){
SystemParametersInfo(20,0,thePath,3);
}
}
}
'@
add-type $code
#Apply the Change on the system
[Win32.Wallpaper]::SetWallpaper($imgPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment