$sharedFolderPath = "\path\to\shared\folder" # Replace with the path to your shared folder containing the images $localFolderPath = "$env:USERPROFILE\Pictures\SlideshowImages"
if (-not (Test-Path $localFolderPath)) { New-Item -ItemType Directory -Path $localFolderPath }
$sharedImages = Get-ChildItem -Path $sharedFolderPath -File foreach ($image in $sharedImages) { Copy-Item -Path $image.FullName -Destination $localFolderPath -Force }
$BackgroundKeyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers" Set-ItemProperty -Path $BackgroundKeyPath -Name BackgroundType -Type DWord -Value 2 Set-ItemProperty -Path $BackgroundKeyPath -Name SlideshowDirectoryPath1 -Type String -Value $localFolderPath
$LockScreenKeyPath = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Personalization" Set-ItemProperty -Path $LockScreenKeyPath -Name LockScreenSlideshow -Type DWord -Value 1 Set-ItemProperty -Path $LockScreenKeyPath -Name LockScreenSlideshowDirectory -Type String -Value $localFolderPath
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True