# Set file paths
$lockFilePath = 'c:\windows\system32\oobe\info\backgrounds'
$lockFileName = 'c:\windows\system32\oobe\info\backgrounds\backgroundDefault.jpg'
# Check the path to the lock file
If(!(Test-Path $lockFilePath)) {
New-Item $lockFilePath -type directory
}
else {
}
# Check in registry if the lock file picture can be set, enable if not present or disabled
try {
$lockFileRegkey=(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" OEMBackground -ErrorAction Stop).OEMBackground
if ($lockFileRegKey -eq '1') {
}
else {
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" -Name OEMBackground -PropertyType DWord -Value 1 -Force
}
}
catch [System.Management.Automation.ItemNotFoundException],[System.Management.Automation.PSArgumentException] {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background"
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" -Name OEMBackground -PropertyType DWord -Value 1
}
# Get current wallpaper from registry, abort if not found
try {
$WallpaperSource=(Get-ItemProperty "HKCU:\Software\Microsoft\Internet Explorer\Desktop\General" WallpaperSource -ErrorAction Stop).WallpaperSource
}
catch [System.Management.Automation.ItemNotFoundException],[System.Management.Automation.PSArgumentException] {
"Wallpaper not found. Aborting."
break;
}
# Copy wallpaper to lock file
Copy-Item -Path $WallpaperSource -Destination $lockFileName -Force