diff --git a/resources/Microsoft.Windows.Settings/Microsoft.Windows.Settings.psm1 b/resources/Microsoft.Windows.Settings/Microsoft.Windows.Settings.psm1 index 868cc3fe..8d2c385b 100644 --- a/resources/Microsoft.Windows.Settings/Microsoft.Windows.Settings.psm1 +++ b/resources/Microsoft.Windows.Settings/Microsoft.Windows.Settings.psm1 @@ -14,8 +14,12 @@ if ([string]::IsNullOrEmpty($env:TestRegistryPath)) { $global:DWMRegistryPath = 'HKCU:\Software\Microsoft\Windows\DWM\' $global:StartRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Start\' $global:USBRegistryPath = 'HKCU:\Software\Microsoft\Shell\USB\' + $global:TaskbarBadgesRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarBadges\' + $global:TaskbarGlomLevelRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\MMTaskbarGlomLevel\' + $global:TaskbarMultiMonRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\MMTaskbarEnabled\' + $global:TaskbarMultiMonModeRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\MMTaskbarMode\' } else { - $global:ExplorerRegistryPath = $global:PersonalizeRegistryPath = $global:AppModelUnlockRegistryPath = $global:TimeZoneAutoUpdateRegistryPath = $global:TimeZoneInformationRegistryPath = $global:DesktopRegistryPath = $global:DWMRegistryPath = $global:StartRegistryPath = $global:USBRegistryPath = $env:TestRegistryPath + $global:ExplorerRegistryPath = $global:PersonalizeRegistryPath = $global:AppModelUnlockRegistryPath = $global:TimeZoneAutoUpdateRegistryPath = $global:TimeZoneInformationRegistryPath = $global:DesktopRegistryPath = $global:DWMRegistryPath = $global:StartRegistryPath = $global:USBRegistryPath = $global:TaskbarBadgesRegistryPath = $global:TaskbarGlomLevelRegistryPath = $global:TaskbarMultiMonRegistryPath = $global:TaskbarMultiMonModeRegistryPath = $env:TestRegistryPath } [DSCResource()] @@ -59,6 +63,39 @@ class WindowsSettings { [DscProperty()] [string[]] $StartFolders + # Personalization - Start Layout + [DscProperty()] + [Nullable[bool]] $ShowRecentList + + # Personalization - Recommended files + [DscProperty()] + [Nullable[bool]] $ShowRecommendedList + + # Taskbar - Badges + [DscProperty()] + [Nullable[bool]] $TaskbarBadges + + [DscProperty()] + [Nullable[bool]] $DesktopTaskbarBadges + + # Taskbar - Grouping Mode (not making enum to allow if user does not want to set) + [DscProperty()] + [string] $TaskbarGroupingMode + + # Taskbar - Multi-Monitor + [DscProperty()] + [Nullable[bool]] $TaskbarMultiMon + + [DscProperty()] + [Nullable[bool]] $DesktopTaskbarMultiMon + + # Taskbar - Multi-Monitor Mode + [DscProperty()] + [string] $TaskbarMultiMonMode + + [DscProperty()] + [string] $DesktopTaskbarMultiMonMode + [DscProperty()] [Nullable[bool]] $NotifyOnUsbErrors @@ -79,6 +116,15 @@ class WindowsSettings { hidden [string] $ColorPrevalenceDWMPropertyName = 'ColorPrevalence' hidden [string] $AutoColorizationPropertyName = 'AutoColorization' hidden [string] $VisiblePlacesPropertyName = 'VisiblePlaces' + hidden [string] $ShowRecentListPropertyName = 'ShowRecentList' + hidden [string] $StartTrackDocsPropertyName = 'Start_TrackDocs' + hidden [string] $TaskbarBadgingPropertyName = 'SystemSettings_Taskbar_Badging' + hidden [string] $DesktopTaskbarBadgingPropertyName = 'SystemSettings_DesktopTaskbar_Badging' + hidden [string] $TaskbarGroupingModePropertyName = 'SystemSettings_DesktopTaskbar_GroupingMode' + hidden [string] $TaskbarMultiMonPropertyName = 'SystemSettings_Taskbar_MultiMon' + hidden [string] $DesktopTaskbarMultiMonPropertyName = 'SystemSettings_DesktopTaskbar_MultiMon' + hidden [string] $TaskbarMultiMonModePropertyName = 'SystemSettings_Taskbar_MultiMonTaskbarMode' + hidden [string] $DesktopTaskbarMultiMonModePropertyName = 'SystemSettings_DesktopTaskbar_MultiMonTaskbarMode' hidden [string] $NotifyOnUsbErrorsPropertyName = 'NotifyOnUsbErrors' hidden [string] $NotifyOnWeakChargerPropertyName = 'NotifyOnWeakCharger' @@ -121,6 +167,19 @@ class WindowsSettings { # Get Start Folders $currentState.StartFolders = $this.GetStartFolders() + # Get Start Layout settings + $currentState.ShowRecentList = $this.GetShowRecentList() + $currentState.ShowRecommendedList = $this.GetShowRecommendedList() + + # Get Taskbar settings + $currentState.TaskbarBadges = $this.GetTaskbarBadges() + $currentState.DesktopTaskbarBadges = $this.GetDesktopTaskbarBadges() + $currentState.TaskbarGroupingMode = $this.GetTaskbarGroupingMode() + $currentState.TaskbarMultiMon = $this.GetTaskbarMultiMon() + $currentState.DesktopTaskbarMultiMon = $this.GetDesktopTaskbarMultiMon() + $currentState.TaskbarMultiMonMode = $this.GetTaskbarMultiMonMode() + $currentState.DesktopTaskbarMultiMonMode = $this.GetDesktopTaskbarMultiMonMode() + # Get USB settings $currentState.NotifyOnUsbErrors = $this.GetNotifyOnUsbErrors() $currentState.NotifyOnWeakCharger = $this.GetNotifyOnWeakCharger() @@ -130,7 +189,28 @@ class WindowsSettings { [bool] Test() { $currentState = $this.Get() - return $this.TestTaskbarAlignment($currentState) -and $this.TestAppColorMode($currentState) -and $this.TestSystemColorMode($currentState) -and $this.TestDeveloperMode($currentState) -and $this.TestSetTimeZoneAutomatically($currentState) -and $this.TestTimeZone($currentState) -and $this.TestEnableTransparency($currentState) -and $this.TestShowAccentColorOnStartAndTaskbar($currentState) -and $this.TestShowAccentColorOnTitleBarsAndWindowBorders($currentState) -and $this.TestAutoColorization($currentState) -and $this.TestStartFolders($currentState) -and $this.TestNotifyOnUsbErrors($currentState) -and $this.TestNotifyOnWeakCharger($currentState) + return $this.TestTaskbarAlignment($currentState) -and + $this.TestAppColorMode($currentState) -and + $this.TestSystemColorMode($currentState) -and + $this.TestDeveloperMode($currentState) -and + $this.TestSetTimeZoneAutomatically($currentState) -and + $this.TestTimeZone($currentState) -and + $this.TestEnableTransparency($currentState) -and + $this.TestShowAccentColorOnStartAndTaskbar($currentState) -and + $this.TestShowAccentColorOnTitleBarsAndWindowBorders($currentState) -and + $this.TestAutoColorization($currentState) -and + $this.TestStartFolders($currentState) -and + $this.TestShowRecentList($currentState) -and + $this.TestShowRecommendedList($currentState) -and + $this.TestTaskbarBadges($currentState) -and + $this.TestDesktopTaskbarBadges($currentState) -and + $this.TestTaskbarGroupingMode($currentState) -and + $this.TestTaskbarMultiMon($currentState) -and + $this.TestDesktopTaskbarMultiMon($currentState) -and + $this.TestTaskbarMultiMonMode($currentState) -and + $this.TestDesktopTaskbarMultiMonMode($currentState) -and + $this.TestNotifyOnUsbErrors($currentState) -and + $this.TestNotifyOnWeakCharger($currentState) } [void] Set() { @@ -238,6 +318,99 @@ class WindowsSettings { $this.SetStartFolders() } + # Set Start Layout settings + if (!$this.TestShowRecentList($currentState)) { + if (-not (Test-Path $global:StartRegistryPath)) { + New-Item -Path $global:StartRegistryPath -Force | Out-Null + } + $value = $this.ShowRecentList ? 1 : 0 + Set-ItemProperty -Path $global:StartRegistryPath -Name $this.ShowRecentListPropertyName -Value $value -Type DWord + } + + # Set ShowRecommendedList (Start_TrackDocs) + if (!$this.TestShowRecommendedList($currentState)) { + $value = $this.ShowRecommendedList ? 1 : 0 + Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.StartTrackDocsPropertyName -Value $value -Type DWord + } + + # Set TaskbarBadges + if (!$this.TestTaskbarBadges($currentState)) { + if (-not (Test-Path $global:TaskbarBadgesRegistryPath)) { + New-Item -Path $global:TaskbarBadgesRegistryPath -Force | Out-Null + } + $value = $this.TaskbarBadges ? '1' : '0' + Set-ItemProperty -Path $global:TaskbarBadgesRegistryPath -Name $this.TaskbarBadgingPropertyName -Value $value -Type String + } + + # Set DesktopTaskbarBadges + if (!$this.TestDesktopTaskbarBadges($currentState)) { + if (-not (Test-Path $global:TaskbarBadgesRegistryPath)) { + New-Item -Path $global:TaskbarBadgesRegistryPath -Force | Out-Null + } + $value = $this.DesktopTaskbarBadges ? '1' : '0' + Set-ItemProperty -Path $global:TaskbarBadgesRegistryPath -Name $this.DesktopTaskbarBadgingPropertyName -Value $value -Type String + } + + # Set TaskbarGroupingMode + if (!$this.TestTaskbarGroupingMode($currentState)) { + if (-not (Test-Path $global:TaskbarGlomLevelRegistryPath)) { + New-Item -Path $global:TaskbarGlomLevelRegistryPath -Force | Out-Null + } + $value = switch ($this.TaskbarGroupingMode) { + 'Always' { '0' } + 'WhenFull' { '1' } + 'Never' { '2' } + default { throw "Invalid TaskbarGroupingMode: $($this.TaskbarGroupingMode). Valid values are: Always, WhenFull, Never" } + } + Set-ItemProperty -Path $global:TaskbarGlomLevelRegistryPath -Name $this.TaskbarGroupingModePropertyName -Value $value -Type String + } + + # Set TaskbarMultiMon + if (!$this.TestTaskbarMultiMon($currentState)) { + if (-not (Test-Path $global:TaskbarMultiMonRegistryPath)) { + New-Item -Path $global:TaskbarMultiMonRegistryPath -Force | Out-Null + } + $value = $this.TaskbarMultiMon ? '1' : '0' + Set-ItemProperty -Path $global:TaskbarMultiMonRegistryPath -Name $this.TaskbarMultiMonPropertyName -Value $value -Type String + } + + # Set DesktopTaskbarMultiMon + if (!$this.TestDesktopTaskbarMultiMon($currentState)) { + if (-not (Test-Path $global:TaskbarMultiMonRegistryPath)) { + New-Item -Path $global:TaskbarMultiMonRegistryPath -Force | Out-Null + } + $value = $this.DesktopTaskbarMultiMon ? '1' : '0' + Set-ItemProperty -Path $global:TaskbarMultiMonRegistryPath -Name $this.DesktopTaskbarMultiMonPropertyName -Value $value -Type String + } + + # Set TaskbarMultiMonMode + if (!$this.TestTaskbarMultiMonMode($currentState)) { + if (-not (Test-Path $global:TaskbarMultiMonModeRegistryPath)) { + New-Item -Path $global:TaskbarMultiMonModeRegistryPath -Force | Out-Null + } + $value = switch ($this.TaskbarMultiMonMode) { + 'Duplicate' { '0' } + 'PrimaryAndWindow' { '1' } + 'WindowOnly' { '2' } + default { throw "Invalid TaskbarMultiMonMode: $($this.TaskbarMultiMonMode). Valid values are: Duplicate, PrimaryAndWindow, WindowOnly" } + } + Set-ItemProperty -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.TaskbarMultiMonModePropertyName -Value $value -Type String + } + + # Set DesktopTaskbarMultiMonMode + if (!$this.TestDesktopTaskbarMultiMonMode($currentState)) { + if (-not (Test-Path $global:TaskbarMultiMonModeRegistryPath)) { + New-Item -Path $global:TaskbarMultiMonModeRegistryPath -Force | Out-Null + } + $value = switch ($this.DesktopTaskbarMultiMonMode) { + 'Duplicate' { '0' } + 'PrimaryAndWindow' { '1' } + 'WindowOnly' { '2' } + default { throw "Invalid DesktopTaskbarMultiMonMode: $($this.DesktopTaskbarMultiMonMode). Valid values are: Duplicate, PrimaryAndWindow, WindowOnly" } + } + Set-ItemProperty -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.DesktopTaskbarMultiMonModePropertyName -Value $value -Type String + } + # Set USB settings if (!$this.TestNotifyOnUsbErrors($currentState)) { # Ensure registry path exists @@ -490,6 +663,158 @@ class WindowsSettings { return $true } + # Start Layout Helper Methods + [Nullable[bool]] GetShowRecentList() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:StartRegistryPath -Name $this.ShowRecentListPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:StartRegistryPath -Name $this.ShowRecentListPropertyName + return $value -eq 1 + } + + [bool] TestShowRecentList([WindowsSettings] $currentState) { + if ($null -eq $this.ShowRecentList) { + return $true + } + return $currentState.ShowRecentList -eq $this.ShowRecentList + } + + [Nullable[bool]] GetShowRecommendedList() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.StartTrackDocsPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.StartTrackDocsPropertyName + return $value -eq 1 + } + + [bool] TestShowRecommendedList([WindowsSettings] $currentState) { + if ($null -eq $this.ShowRecommendedList) { + return $true + } + return $currentState.ShowRecommendedList -eq $this.ShowRecommendedList + } + + # Taskbar Helper Methods + [Nullable[bool]] GetTaskbarBadges() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarBadgesRegistryPath -Name $this.TaskbarBadgingPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarBadgesRegistryPath -Name $this.TaskbarBadgingPropertyName + return $value -eq '1' + } + + [bool] TestTaskbarBadges([WindowsSettings] $currentState) { + if ($null -eq $this.TaskbarBadges) { + return $true + } + return $currentState.TaskbarBadges -eq $this.TaskbarBadges + } + + [Nullable[bool]] GetDesktopTaskbarBadges() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarBadgesRegistryPath -Name $this.DesktopTaskbarBadgingPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarBadgesRegistryPath -Name $this.DesktopTaskbarBadgingPropertyName + return $value -eq '1' + } + + [bool] TestDesktopTaskbarBadges([WindowsSettings] $currentState) { + if ($null -eq $this.DesktopTaskbarBadges) { + return $true + } + return $currentState.DesktopTaskbarBadges -eq $this.DesktopTaskbarBadges + } + + [object] GetTaskbarGroupingMode() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarGlomLevelRegistryPath -Name $this.TaskbarGroupingModePropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarGlomLevelRegistryPath -Name $this.TaskbarGroupingModePropertyName + switch ($value) { + '0' { return 'Always' } + '1' { return 'WhenFull' } + '2' { return 'Never' } + } + return $null + } + + [bool] TestTaskbarGroupingMode([WindowsSettings] $currentState) { + if ([string]::IsNullOrEmpty($this.TaskbarGroupingMode)) { + return $true + } + return $currentState.TaskbarGroupingMode -eq $this.TaskbarGroupingMode + } + + [Nullable[bool]] GetTaskbarMultiMon() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarMultiMonRegistryPath -Name $this.TaskbarMultiMonPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarMultiMonRegistryPath -Name $this.TaskbarMultiMonPropertyName + return $value -eq '1' + } + + [bool] TestTaskbarMultiMon([WindowsSettings] $currentState) { + if ($null -eq $this.TaskbarMultiMon) { + return $true + } + return $currentState.TaskbarMultiMon -eq $this.TaskbarMultiMon + } + + [Nullable[bool]] GetDesktopTaskbarMultiMon() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarMultiMonRegistryPath -Name $this.DesktopTaskbarMultiMonPropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarMultiMonRegistryPath -Name $this.DesktopTaskbarMultiMonPropertyName + return $value -eq '1' + } + + [bool] TestDesktopTaskbarMultiMon([WindowsSettings] $currentState) { + if ($null -eq $this.DesktopTaskbarMultiMon) { + return $true + } + return $currentState.DesktopTaskbarMultiMon -eq $this.DesktopTaskbarMultiMon + } + + [string] GetTaskbarMultiMonMode() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.TaskbarMultiMonModePropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.TaskbarMultiMonModePropertyName + switch ($value) { + '0' { return 'Duplicate' } + '1' { return 'PrimaryAndWindow' } + '2' { return 'WindowOnly' } + } + return $null + } + + [bool] TestTaskbarMultiMonMode([WindowsSettings] $currentState) { + if ([string]::IsNullOrEmpty($this.TaskbarMultiMonMode)) { + return $true + } + return $currentState.TaskbarMultiMonMode -eq $this.TaskbarMultiMonMode + } + + [string] GetDesktopTaskbarMultiMonMode() { + if (-not(DoesRegistryKeyPropertyExist -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.DesktopTaskbarMultiMonModePropertyName)) { + return $null + } + $value = Get-ItemPropertyValue -Path $global:TaskbarMultiMonModeRegistryPath -Name $this.DesktopTaskbarMultiMonModePropertyName + switch ($value) { + '0' { return 'Duplicate' } + '1' { return 'PrimaryAndWindow' } + '2' { return 'WindowOnly' } + } + return $null + } + + [bool] TestDesktopTaskbarMultiMonMode([WindowsSettings] $currentState) { + if ([string]::IsNullOrEmpty($this.DesktopTaskbarMultiMonMode)) { + return $true + } + return $currentState.DesktopTaskbarMultiMonMode -eq $this.DesktopTaskbarMultiMonMode + } + [bool] TestNotifyOnUsbErrors([WindowsSettings] $currentState) { if ($null -eq $this.NotifyOnUsbErrors) { return $true diff --git a/samples/DscResources/Microsoft.Windows.Settings/PersonalizationSettings.winget b/samples/DscResources/Microsoft.Windows.Settings/PersonalizationSettings.winget index 00512fca..b94250f4 100644 --- a/samples/DscResources/Microsoft.Windows.Settings/PersonalizationSettings.winget +++ b/samples/DscResources/Microsoft.Windows.Settings/PersonalizationSettings.winget @@ -26,4 +26,31 @@ properties: - Downloads - Settings - Explorer + + # Start Layout Settings + # ShowRecentList: Show recently installed apps in Start + ShowRecentList: true + # ShowRecommendedList: Show recommended files in Start, recent files in File Explorer, and items in Jump Lists + ShowRecommendedList: true + + # Taskbar Settings + # TaskbarBadges: Enable badges (unread message counts, etc.) for apps on the taskbar + TaskbarBadges: true + # DesktopTaskbarBadges: Enable badges for apps on the desktop taskbar + DesktopTaskbarBadges: true + # TaskbarGroupingMode: Control how taskbar buttons are grouped + # Valid values: Always, WhenFull, Never + TaskbarGroupingMode: Always + # TaskbarMultiMon: Show taskbar on multiple displays + TaskbarMultiMon: true + # DesktopTaskbarMultiMon: Show taskbar on multiple displays (desktop) + DesktopTaskbarMultiMon: true + # TaskbarMultiMonMode: Control how windows are shown on taskbars across monitors + # Valid values: Duplicate, PrimaryAndWindow, WindowOnly + # - Duplicate: Show all windows on all taskbars + # - PrimaryAndWindow: Show on main taskbar and on the taskbar where the window is open + # - WindowOnly: Show only on the taskbar where the window is open + TaskbarMultiMonMode: Duplicate + # DesktopTaskbarMultiMonMode: Control how windows are shown on taskbars across monitors (desktop) + DesktopTaskbarMultiMonMode: Duplicate configurationVersion: 0.2.0 diff --git a/tests/Microsoft.Windows.Settings/Microsoft.Windows.Settings.Tests.ps1 b/tests/Microsoft.Windows.Settings/Microsoft.Windows.Settings.Tests.ps1 index 2c808bae..d6b5dcb4 100644 --- a/tests/Microsoft.Windows.Settings/Microsoft.Windows.Settings.Tests.ps1 +++ b/tests/Microsoft.Windows.Settings/Microsoft.Windows.Settings.Tests.ps1 @@ -36,6 +36,15 @@ BeforeAll { $script:originalSettings.ShowAccentColorOnTitleBarsAndWindowBorders = $currentState.ShowAccentColorOnTitleBarsAndWindowBorders $script:originalSettings.AutoColorization = $currentState.AutoColorization $script:originalSettings.StartFolders = $currentState.StartFolders + $script:originalSettings.ShowRecentList = $currentState.ShowRecentList + $script:originalSettings.ShowRecommendedList = $currentState.ShowRecommendedList + $script:originalSettings.TaskbarBadges = $currentState.TaskbarBadges + $script:originalSettings.DesktopTaskbarBadges = $currentState.DesktopTaskbarBadges + $script:originalSettings.TaskbarGroupingMode = $currentState.TaskbarGroupingMode + $script:originalSettings.TaskbarMultiMon = $currentState.TaskbarMultiMon + $script:originalSettings.DesktopTaskbarMultiMon = $currentState.DesktopTaskbarMultiMon + $script:originalSettings.TaskbarMultiMonMode = $currentState.TaskbarMultiMonMode + $script:originalSettings.DesktopTaskbarMultiMonMode = $currentState.DesktopTaskbarMultiMonMode $script:originalSettings.NotifyOnUsbErrors = $currentState.NotifyOnUsbErrors $script:originalSettings.NotifyOnWeakCharger = $currentState.NotifyOnWeakCharger @@ -51,6 +60,15 @@ BeforeAll { Write-Host " ShowAccentColorOnTitleBarsAndWindowBorders: $($script:originalSettings.ShowAccentColorOnTitleBarsAndWindowBorders)" Write-Host " AutoColorization: $($script:originalSettings.AutoColorization)" Write-Host " StartFolders: $($script:originalSettings.StartFolders -join ', ')" + Write-Host " ShowRecentList: $($script:originalSettings.ShowRecentList)" + Write-Host " ShowRecommendedList: $($script:originalSettings.ShowRecommendedList)" + Write-Host " TaskbarBadges: $($script:originalSettings.TaskbarBadges)" + Write-Host " DesktopTaskbarBadges: $($script:originalSettings.DesktopTaskbarBadges)" + Write-Host " TaskbarGroupingMode: $($script:originalSettings.TaskbarGroupingMode)" + Write-Host " TaskbarMultiMon: $($script:originalSettings.TaskbarMultiMon)" + Write-Host " DesktopTaskbarMultiMon: $($script:originalSettings.DesktopTaskbarMultiMon)" + Write-Host " TaskbarMultiMonMode: $($script:originalSettings.TaskbarMultiMonMode)" + Write-Host " DesktopTaskbarMultiMonMode: $($script:originalSettings.DesktopTaskbarMultiMonMode)" Write-Host " NotifyOnUsbErrors: $($script:originalSettings.NotifyOnUsbErrors)" Write-Host " NotifyOnWeakCharger: $($script:originalSettings.NotifyOnWeakCharger)" } @@ -92,6 +110,33 @@ AfterAll { if ($null -ne $script:originalSettings.StartFolders -and $script:originalSettings.StartFolders.Count -gt 0) { $restoreSettings.StartFolders = $script:originalSettings.StartFolders } + if ($null -ne $script:originalSettings.ShowRecentList) { + $restoreSettings.ShowRecentList = $script:originalSettings.ShowRecentList + } + if ($null -ne $script:originalSettings.ShowRecommendedList) { + $restoreSettings.ShowRecommendedList = $script:originalSettings.ShowRecommendedList + } + if ($null -ne $script:originalSettings.TaskbarBadges) { + $restoreSettings.TaskbarBadges = $script:originalSettings.TaskbarBadges + } + if ($null -ne $script:originalSettings.DesktopTaskbarBadges) { + $restoreSettings.DesktopTaskbarBadges = $script:originalSettings.DesktopTaskbarBadges + } + if (-not [string]::IsNullOrEmpty($script:originalSettings.TaskbarGroupingMode)) { + $restoreSettings.TaskbarGroupingMode = $script:originalSettings.TaskbarGroupingMode + } + if ($null -ne $script:originalSettings.TaskbarMultiMon) { + $restoreSettings.TaskbarMultiMon = $script:originalSettings.TaskbarMultiMon + } + if ($null -ne $script:originalSettings.DesktopTaskbarMultiMon) { + $restoreSettings.DesktopTaskbarMultiMon = $script:originalSettings.DesktopTaskbarMultiMon + } + if (-not [string]::IsNullOrEmpty($script:originalSettings.TaskbarMultiMonMode)) { + $restoreSettings.TaskbarMultiMonMode = $script:originalSettings.TaskbarMultiMonMode + } + if (-not [string]::IsNullOrEmpty($script:originalSettings.DesktopTaskbarMultiMonMode)) { + $restoreSettings.DesktopTaskbarMultiMonMode = $script:originalSettings.DesktopTaskbarMultiMonMode + } if ($null -ne $script:originalSettings.NotifyOnUsbErrors) { $restoreSettings.NotifyOnUsbErrors = $script:originalSettings.NotifyOnUsbErrors } @@ -818,6 +863,548 @@ Describe 'WindowsSettings - Start Folders' { $settings.Test() | Should -Be $true } } + +Describe 'WindowsSettings - ShowRecentList' { + It 'Gets current ShowRecentList' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be either $true, $false, or $null + $currentState.ShowRecentList | Should -BeIn @($true, $false, $null) + } + + It 'Sets ShowRecentList to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.ShowRecentList = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.ShowRecentList | Should -Be $true + } + + It 'Sets ShowRecentList to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.ShowRecentList = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.ShowRecentList | Should -Be $false + } + + It 'Tests ShowRecentList when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.ShowRecentList = $currentState.ShowRecentList + + $settings.Test() | Should -Be $true + } + + It 'Tests ShowRecentList when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.ShowRecentList = -not $currentState.ShowRecentList + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - ShowRecommendedList' { + It 'Gets current ShowRecommendedList' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + $currentState.ShowRecommendedList | Should -BeIn @($true, $false, $null) + } + + It 'Sets ShowRecommendedList to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.ShowRecommendedList = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.ShowRecommendedList | Should -Be $true + } + + It 'Sets ShowRecommendedList to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.ShowRecommendedList = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.ShowRecommendedList | Should -Be $false + } + + It 'Tests ShowRecommendedList when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.ShowRecommendedList = $currentState.ShowRecommendedList + + $settings.Test() | Should -Be $true + } + + It 'Tests ShowRecommendedList when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.ShowRecommendedList = -not $currentState.ShowRecommendedList + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - TaskbarBadges' { + It 'Gets current TaskbarBadges' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + $currentState.TaskbarBadges | Should -BeIn @($true, $false, $null) + } + + It 'Sets TaskbarBadges to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarBadges = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarBadges | Should -Be $true + } + + It 'Sets TaskbarBadges to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarBadges = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarBadges | Should -Be $false + } + + It 'Tests TaskbarBadges when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.TaskbarBadges = $currentState.TaskbarBadges + + $settings.Test() | Should -Be $true + } + + It 'Tests TaskbarBadges when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.TaskbarBadges = -not $currentState.TaskbarBadges + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - DesktopTaskbarBadges' { + It 'Gets current DesktopTaskbarBadges' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be either $true, $false, or $null + $currentState.DesktopTaskbarBadges | Should -BeIn @($true, $false, $null) + } + + It 'Sets DesktopTaskbarBadges to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarBadges = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarBadges | Should -Be $true + } + + It 'Sets DesktopTaskbarBadges to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarBadges = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarBadges | Should -Be $false + } + + It 'Tests DesktopTaskbarBadges when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.DesktopTaskbarBadges = $currentState.DesktopTaskbarBadges + + $settings.Test() | Should -Be $true + } + + It 'Tests DesktopTaskbarBadges when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.DesktopTaskbarBadges = -not $currentState.DesktopTaskbarBadges + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - TaskbarGroupingMode' { + It 'Gets current TaskbarGroupingMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be either Always, WhenFull, Never, null, or empty string + $currentState.TaskbarGroupingMode | Should -BeIn @('Always', 'WhenFull', 'Never', $null, '') + } + + It 'Sets TaskbarGroupingMode to Always' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarGroupingMode = 'Always' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarGroupingMode | Should -Be 'Always' + } + + It 'Sets TaskbarGroupingMode to WhenFull' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarGroupingMode = 'WhenFull' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarGroupingMode | Should -Be 'WhenFull' + } + + It 'Sets TaskbarGroupingMode to Never' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarGroupingMode = 'Never' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarGroupingMode | Should -Be 'Never' + } + + It 'Tests TaskbarGroupingMode when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.TaskbarGroupingMode = $currentState.TaskbarGroupingMode + + $settings.Test() | Should -Be $true + } + + It 'Throws error for invalid TaskbarGroupingMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarGroupingMode = 'InvalidValue' + + { $settings.Set() } | Should -Throw '*Invalid TaskbarGroupingMode*' + } +} + +Describe 'WindowsSettings - TaskbarMultiMon' { + It 'Gets current TaskbarMultiMon' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be either $true, $false, or $null + $currentState.TaskbarMultiMon | Should -BeIn @($true, $false, $null) + } + + It 'Sets TaskbarMultiMon to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMon = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarMultiMon | Should -Be $true + } + + It 'Sets TaskbarMultiMon to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMon = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarMultiMon | Should -Be $false + } + + It 'Tests TaskbarMultiMon when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.TaskbarMultiMon = $currentState.TaskbarMultiMon + + $settings.Test() | Should -Be $true + } + + It 'Tests TaskbarMultiMon when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.TaskbarMultiMon = -not $currentState.TaskbarMultiMon + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - DesktopTaskbarMultiMon' { + It 'Gets current DesktopTaskbarMultiMon' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be either $true, $false, or $null + $currentState.DesktopTaskbarMultiMon | Should -BeIn @($true, $false, $null) + } + + It 'Sets DesktopTaskbarMultiMon to enabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMon = $true + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarMultiMon | Should -Be $true + } + + It 'Sets DesktopTaskbarMultiMon to disabled' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMon = $false + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarMultiMon | Should -Be $false + } + + It 'Tests DesktopTaskbarMultiMon when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + $settings.DesktopTaskbarMultiMon = $currentState.DesktopTaskbarMultiMon + + $settings.Test() | Should -Be $true + } + + It 'Tests DesktopTaskbarMultiMon when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Set opposite value + $settings.DesktopTaskbarMultiMon = -not $currentState.DesktopTaskbarMultiMon + + $settings.Test() | Should -Be $false + } +} + +Describe 'WindowsSettings - TaskbarMultiMonMode' { + It 'Gets current TaskbarMultiMonMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be one of the valid values, null, or empty string + $currentState.TaskbarMultiMonMode | Should -BeIn @('Duplicate', 'PrimaryAndWindow', 'WindowOnly', $null, '') + } + + It 'Sets TaskbarMultiMonMode to Duplicate' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMonMode = 'Duplicate' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarMultiMonMode | Should -Be 'Duplicate' + } + + It 'Sets TaskbarMultiMonMode to PrimaryAndWindow' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMonMode = 'PrimaryAndWindow' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarMultiMonMode | Should -Be 'PrimaryAndWindow' + } + + It 'Sets TaskbarMultiMonMode to WindowOnly' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMonMode = 'WindowOnly' + + $settings.Set() + + $newState = $settings.Get() + $newState.TaskbarMultiMonMode | Should -Be 'WindowOnly' + } + + It 'Tests TaskbarMultiMonMode when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + + # First set a known value + $settings.TaskbarMultiMonMode = 'Duplicate' + $settings.Set() + + # Now test with same value + $testSettings = [WindowsSettings]::new() + $testSettings.SID = 'TestSID' + $testSettings.TaskbarMultiMonMode = 'Duplicate' + + $testSettings.Test() | Should -Be $true + } + + It 'Tests TaskbarMultiMonMode when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + + # First set a known value + $settings.TaskbarMultiMonMode = 'Duplicate' + $settings.Set() + + # Now test with different value + $testSettings = [WindowsSettings]::new() + $testSettings.SID = 'TestSID' + $testSettings.TaskbarMultiMonMode = 'WindowOnly' + + $testSettings.Test() | Should -Be $false + } + + It 'Throws error for invalid TaskbarMultiMonMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.TaskbarMultiMonMode = 'InvalidValue' + + { $settings.Set() } | Should -Throw '*Invalid TaskbarMultiMonMode*' + } +} + +Describe 'WindowsSettings - DesktopTaskbarMultiMonMode' { + It 'Gets current DesktopTaskbarMultiMonMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $currentState = $settings.Get() + + # Should be one of the valid values, null, or empty string + $currentState.DesktopTaskbarMultiMonMode | Should -BeIn @('Duplicate', 'PrimaryAndWindow', 'WindowOnly', $null, '') + } + + It 'Sets DesktopTaskbarMultiMonMode to Duplicate' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMonMode = 'Duplicate' + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarMultiMonMode | Should -Be 'Duplicate' + } + + It 'Sets DesktopTaskbarMultiMonMode to PrimaryAndWindow' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMonMode = 'PrimaryAndWindow' + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarMultiMonMode | Should -Be 'PrimaryAndWindow' + } + + It 'Sets DesktopTaskbarMultiMonMode to WindowOnly' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMonMode = 'WindowOnly' + + $settings.Set() + + $newState = $settings.Get() + $newState.DesktopTaskbarMultiMonMode | Should -Be 'WindowOnly' + } + + It 'Tests DesktopTaskbarMultiMonMode when values match' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + + $settings.DesktopTaskbarMultiMonMode = 'Duplicate' + $settings.Set() + + $testSettings = [WindowsSettings]::new() + $testSettings.SID = 'TestSID' + $testSettings.DesktopTaskbarMultiMonMode = 'Duplicate' + + $testSettings.Test() | Should -Be $true + } + + It 'Tests DesktopTaskbarMultiMonMode when values differ' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + + $settings.DesktopTaskbarMultiMonMode = 'Duplicate' + $settings.Set() + + $testSettings = [WindowsSettings]::new() + $testSettings.SID = 'TestSID' + $testSettings.DesktopTaskbarMultiMonMode = 'WindowOnly' + + $testSettings.Test() | Should -Be $false + } + + It 'Throws error for invalid DesktopTaskbarMultiMonMode' { + $settings = [WindowsSettings]::new() + $settings.SID = 'TestSID' + $settings.DesktopTaskbarMultiMonMode = 'InvalidValue' + + { $settings.Set() } | Should -Throw '*Invalid DesktopTaskbarMultiMonMode*' + } +} + Describe 'WindowsSettings - USB' { It 'Gets current NotifyOnUsbErrors' { $settings = [WindowsSettings]::new() @@ -842,7 +1429,6 @@ Describe 'WindowsSettings - USB' { $settings.SID = 'TestSID' $currentState = $settings.Get() - # Set opposite value to ensure change $settings.NotifyOnUsbErrors = -not $currentState.NotifyOnUsbErrors $settings.Test() | Should -Be $false @@ -857,7 +1443,6 @@ Describe 'WindowsSettings - USB' { $settings.SID = 'TestSID' $currentState = $settings.Get() - # Set opposite value to ensure change $settings.NotifyOnWeakCharger = -not $currentState.NotifyOnWeakCharger $settings.Test() | Should -Be $false