-
Notifications
You must be signed in to change notification settings - Fork 0
/
LockScreenImage.ps1
36 lines (28 loc) · 1.76 KB
/
LockScreenImage.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Usage: LockScreenImage - LockScreenImageSource ""
#This script requires Administrator privileges
#Personalization CSP is a registry key added as part of windows 10 1703 edition. For more information visit https://docs.microsoft.com/en-us/windows/client-management/mdm/personalization-csp
Param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$LockScreenImageSource
)
$PersonalizationRegistryKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$RootFolder = "C:\Windows\System32"
$LocalImageFolder = "C:\Windows\System32\Personalization"
$LocalImage = "C:\Windows\System32\Personalization\LockScreenImage.jpg"
if(!(Test-Path $PersonalizationRegistryKeyPath)) {
Write-Host "Registry path $($PersonalizationRegistryKeyPath) does not exist. Creating..."
New-Item -Path $PersonalizationRegistryKeyPath -Force | Out-Null
}
if ($LockScreenImageSource) {
Write-Host "Copying Lock Screen image from $($LockScreenImageSource) to local system $($LocalImage)."
if(!(Test-Path $LocalImageFolder)){
New-Item -Path $RootFolder -Name "Personalization" -ItemType "directory"
}
Copy-Item $LockScreenImageSource $LocalImage -Force
Write-Host "Creating PersonalizationCSP registry entries for Lock Screen"
New-ItemProperty -Path $PersonalizationRegistryKeyPath -Name "LockScreenImageStatus" -Value "1" -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $PersonalizationRegistryKeyPath -Name "LockScreenImagePath" -Value $LocalImage -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $PersonalizationRegistryKeyPath -Name "LockScreenImageUrl" -Value $LocalImage -PropertyType STRING -Force | Out-Null
Write-Host "Entries created."
}