• This topic has 2 replies, 2 voices, and was last updated October 6, 2020 by Chad F.

Change wallpaper script

  • Does anyone have a PS script to change the wallpaper for the test failover vm guests vpg’s?  I’m looking to change up the look so the admins know they are working on a different environment as to not be confused with production when working with and testing the failover site and RDP’d into it.

    If you’re failing over to a different hypervisor (ie VMWare –> Azure  etc) it’s pretty simple to detect the change.  We query (Get-WmiObject –query ‘select * from Win32_ComputerSystem’).Manufacturer on VM startup to see if the last scan matches the current value and if not we know a failover happened in one direction or another.  Once you know true/false, replacing the wallpaper image is trivial.

    Here is what someone else posted out on the internet:


    $setwallpapersrc = @”
    using System.Runtime.InteropServices;
    public class wallpaper
    public const int SetDesktopWallpaper = 20;
    public const int UpdateIniFile = 0x01;
    public const int SendWinIniChange = 0x02;
    [DllImport(“user32.dll”, SetLastError = true, CharSet = CharSet.Auto)] private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
    public static void SetWallpaper ( string path )
    SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
    Add-Type -TypeDefinition $setwallpapersrc

You must be logged in to create new topics. Click here to login