Set-LogOnWallpaperRemote
Windows: Configures the Windows Lock Screen image
#Requires -Version 5.1
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[string]$ImagePath,
[bool]$EnableBlur = $true,
[string]$ComputerName = $env:COMPUTERNAME,
[pscredential]$Credential
)
Process {
try {
$scriptBlock = {
Param($Path, $Blur)
$regPathPers = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization"
$regPathSys = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"
if (-not (Test-Path $regPathPers)) {
New-Item -Path $regPathPers -Force | Out-Null
}
if (-not (Test-Path $regPathSys)) {
New-Item -Path $regPathSys -Force | Out-Null
}
Set-ItemProperty -Path $regPathPers -Name "LockScreenImage" -Value $Path -Force -ErrorAction Stop
$blurValue = if ($Blur) { 0 } else { 1 }
Set-ItemProperty -Path $regPathSys -Name "DisableAcrylicBackgroundOnLogon" -Value $blurValue -Force -ErrorAction Stop
}
if ($ComputerName -ne $env:COMPUTERNAME) {
$invokeParams = @{
'ComputerName' = $ComputerName
'ScriptBlock' = $scriptBlock
'ArgumentList' = @($ImagePath, $EnableBlur)
'ErrorAction' = 'Stop'
}
if ($null -ne $Credential) {
$invokeParams.Add('Credential', $Credential)
}
Invoke-Command @invokeParams
}
else {
&$scriptBlock -Path $ImagePath -Blur $EnableBlur
}
$result = [PSCustomObject]@{
ImagePath = $ImagePath
BlurEnabled = $EnableBlur
ComputerName = $ComputerName
Action = "LockScreenConfigured"
Status = "Success"
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $result
}
catch {
throw
}
}Specifies the local path on the target computer for the lock screen image.
If set, enables the acrylic blur effect on the logon screen.
Specifies the name of the target computer. Defaults to the local computer.
Specifies a PSCredential object for remote connection.