How to set slideshow for both Background and Lockscreen using Powershell script?

446 Views Asked by At

I have several images that is needed to deploy as slideshow for both Lockscreen and Background (Windows Background) to selected staff over Intune. How do I use powershell script to do that? Have attempted the following script for background slideshow but my background just turns black

# Set the directory path to your folder of images
$SlideshowFolder = "C:pathtofolder"

# Set the slideshow duration (in seconds)
$SlideshowDuration = 10  # 30 minutes

# Set the transition type (0 for no transition, 1 for fade)
$TransitionType = 1

# Configure the desktop background settings
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name Wallpaper - 
Value ""
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 
WallpaperStyle -Value 6
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name TileWallpaper 
-Value 0
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 
WallpaperChangeInterval -Value $SlideshowDuration
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 
WallpaperTransition -Value $TransitionType

# Set the desktop background to the slideshow folder using 
SystemParametersInfo
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;

public class PInvoke {
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
}
"@

[PInvoke]::SystemParametersInfo(0x0014, 0, $SlideshowFolder, 0x01)

# Refresh the desktop to apply changes
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters
0

There are 0 best solutions below