-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set-Theme.ps1
100 lines (91 loc) · 4.65 KB
/
Set-Theme.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<#
.SYNOPSIS
Change Lock Screen and Desktop Background in Windows 10 Pro.
.DESCRIPTION
This script allows you to change logon screen and desktop background in Windows 10 Professional using GPO startup script.
.PARAMETER LockScreenSource (Optional)
Path to the Lock Screen image to copy locally in computer.
Example: "\\SERVER-FS01\LockScreen.jpg"
.PARAMETER BackgroundSource (Optional)
Path to the Desktop Background image to copy locally in computer.
Example: "\\SERVER-FS01\BackgroundScreen.jpg"
.PARAMETER LogPath (Optional)
Path where save log file. If it's not specified no log is recorded.
.EXAMPLE
Set Lock Screen and Desktop Wallpaper with logs:
Set-LockScreen -LockScreenSource "\\SERVER-FS01\LockScreen.jpg" -BackgroundSource "\\SERVER-FS01\BackgroundScreen.jpg" -LogPath "\\SERVER-FS01\Logs"
.EXAMPLE
Set Lock Screen and Desktop Wallpaper without logs:
Set-LockScreen -LockScreenSource "\\SERVER-FS01\LockScreen.jpg" -BackgroundSource "\\SERVER-FS01\BackgroundScreen.jpg"
.EXAMPLE
Set Lock Screen only:
Set-LockScreen -LockScreenSource "\\SERVER-FS01\LockScreen.jpg" -LogPath "\\SERVER-FS01\Logs"
.EXAMPLE
Set Desktop Wallpaper only:
Set-LockScreen -BackgroundSource "\\SERVER-FS01\BackgroundScreen.jpg" -LogPath "\\SERVER-FS01\Logs"
.NOTES
Author: Chibi ANUBIS
#>
Param(
[Parameter(Mandatory = $false, Position = 0)]
[ValidateNotNullOrEmpty()]
[string]$LockScreenSource,
[Parameter(Mandatory = $false, Position = 1)]
[ValidateNotNullOrEmpty()]
[string]$BackgroundSource,
[Parameter(Mandatory = $false, Position = 2)]
[ValidateNotNullOrEmpty()]
[string]$LogPath
)
#Requires -RunAsAdministrator
if (-not [string]::IsNullOrWhiteSpace($LogPath)) {
Start-Transcript -Path "$($LogPath)\$($env:COMPUTERNAME).log" | Out-Null
}
$ErrorActionPreference = "Stop"
$RegKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP"
$DesktopPath = "DesktopImagePath"
$DesktopStatus = "DesktopImageStatus"
$DesktopUrl = "DesktopImageUrl"
$LockScreenPath = "LockScreenImagePath"
$LockScreenStatus = "LockScreenImageStatus"
$LockScreenUrl = "LockScreenImageUrl"
$StatusValue = "1"
$FolderName = "C:\Windows\Web\Forgital"
$DesktopImageValue = "$FolderName\Desktop.jpg"
$LockScreenImageValue = "$FolderName\LockScreen.jpg"
if (!$LockScreenSource -and !$BackgroundSource) {
Write-Host "Either LockScreenSource or BackgroundSource must has a value."
}
else {
if (!(Test-Path $RegKeyPath)) {
Write-Host "Creating registry path $($RegKeyPath)."
New-Item -Path $RegKeyPath -Force | Out-Null
}
if ($LockScreenSource) {
Write-Host "Copy Lock Screen image from $($LockScreenSource) to $($LockScreenImageValue)."
if (!(Test-Path $FolderName)) {
Write-Host "Creating Folder for local storage"
New-Item $FolderName -ItemType Directory
}
Copy-Item $LockScreenSource $LockScreenImageValue -Force
Write-Host "Creating registry entries for Lock Screen"
New-ItemProperty -Path $RegKeyPath -Name $LockScreenStatus -Value $StatusValue -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenPath -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $LockScreenUrl -Value $LockScreenImageValue -PropertyType STRING -Force | Out-Null
}
if ($BackgroundSource) {
Write-Host "Copy Desktop Background image from $($BackgroundSource) to $($DesktopImageValue)."
if (!(Test-Path $FolderName)) {
Write-Host "Creating Folder for local storage"
New-Item $FolderName -ItemType Directory
}
Copy-Item $BackgroundSource $DesktopImageValue -Force
Write-Host "Creating registry entries for Desktop Background"
New-ItemProperty -Path $RegKeyPath -Name $DesktopStatus -Value $StatusValue -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopPath -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
New-ItemProperty -Path $RegKeyPath -Name $DesktopUrl -Value $DesktopImageValue -PropertyType STRING -Force | Out-Null
}
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenOverlayEnabled" -Value "0" -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -Value "0" -PropertyType DWORD -Force | Out-Null
}
if (-not [string]::IsNullOrWhiteSpace($LogPath)) { Stop-Transcript }