Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac531db05e |
@@ -10,6 +10,7 @@ $ErrorActionPreference = 'Stop'
|
|||||||
$policyKey = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System'
|
$policyKey = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System'
|
||||||
$policyValueName = 'DisableLockWorkstation'
|
$policyValueName = 'DisableLockWorkstation'
|
||||||
$desktopPolicyKey = 'HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop'
|
$desktopPolicyKey = 'HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop'
|
||||||
|
$themeKey = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize'
|
||||||
|
|
||||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
$principal = [Security.Principal.WindowsPrincipal]::new($identity)
|
$principal = [Security.Principal.WindowsPrincipal]::new($identity)
|
||||||
@@ -83,6 +84,19 @@ if ($PSCmdlet.ShouldProcess($GpoName, 'Prevent SGU users from manually locking w
|
|||||||
-Type String `
|
-Type String `
|
||||||
-Value '0' | Out-Null
|
-Value '0' | Out-Null
|
||||||
|
|
||||||
|
# Apply the native Windows dark theme at user logon. Both values are required:
|
||||||
|
# one controls the shell and the other controls supported applications.
|
||||||
|
foreach ($themeValueName in 'AppsUseLightTheme', 'SystemUsesLightTheme') {
|
||||||
|
Set-GPRegistryValue `
|
||||||
|
-Name $GpoName `
|
||||||
|
-Domain $domainName `
|
||||||
|
-Server $DomainController `
|
||||||
|
-Key $themeKey `
|
||||||
|
-ValueName $themeValueName `
|
||||||
|
-Type DWord `
|
||||||
|
-Value 0 | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
if ($WallpaperPath) {
|
if ($WallpaperPath) {
|
||||||
Set-GPRegistryValue `
|
Set-GPRegistryValue `
|
||||||
-Name $GpoName `
|
-Name $GpoName `
|
||||||
@@ -115,6 +129,18 @@ $screenSaverValue = Get-GPRegistryValue `
|
|||||||
-Server $DomainController `
|
-Server $DomainController `
|
||||||
-Key $desktopPolicyKey `
|
-Key $desktopPolicyKey `
|
||||||
-ValueName 'ScreenSaveActive'
|
-ValueName 'ScreenSaveActive'
|
||||||
|
$appsThemeValue = Get-GPRegistryValue `
|
||||||
|
-Name $GpoName `
|
||||||
|
-Domain $domainName `
|
||||||
|
-Server $DomainController `
|
||||||
|
-Key $themeKey `
|
||||||
|
-ValueName 'AppsUseLightTheme'
|
||||||
|
$systemThemeValue = Get-GPRegistryValue `
|
||||||
|
-Name $GpoName `
|
||||||
|
-Domain $domainName `
|
||||||
|
-Server $DomainController `
|
||||||
|
-Key $themeKey `
|
||||||
|
-ValueName 'SystemUsesLightTheme'
|
||||||
$link = @(Get-GPInheritance -Target $TargetOuDn -Domain $domainName -Server $DomainController).GpoLinks |
|
$link = @(Get-GPInheritance -Target $TargetOuDn -Domain $domainName -Server $DomainController).GpoLinks |
|
||||||
Where-Object DisplayName -eq $GpoName |
|
Where-Object DisplayName -eq $GpoName |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
@@ -138,5 +164,6 @@ if ($WallpaperPath) {
|
|||||||
LinkEnabled = [bool]$linkEnabled
|
LinkEnabled = [bool]$linkEnabled
|
||||||
DisableLockWorkstation = [int]$configuredValue.Value
|
DisableLockWorkstation = [int]$configuredValue.Value
|
||||||
ScreenSaverDisabled = [string]$screenSaverValue.Value -eq '0'
|
ScreenSaverDisabled = [string]$screenSaverValue.Value -eq '0'
|
||||||
|
DarkMode = ([int]$appsThemeValue.Value -eq 0) -and ([int]$systemThemeValue.Value -eq 0)
|
||||||
Wallpaper = $configuredWallpaper
|
Wallpaper = $configuredWallpaper
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user