From b0b1125421122f0461e223bc35e2b7dacef093af Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 16 Nov 2024 16:13:12 +0300 Subject: [PATCH] Code refactoring --- Wrapper/Config/config_Windows_10.json | 67 +- Wrapper/Config/config_Windows_10_LTSC.json | 37 +- Wrapper/Config/config_Windows_11.json | 32 - Wrapper/Config/config_Windows_11_LTSC.json | 34 - .../de-DE/tooltip_Windows_10.json | 46 +- .../de-DE/tooltip_Windows_11.json | 28 - .../en-US/tooltip_Windows_10.json | 46 +- .../en-US/tooltip_Windows_11.json | 32 +- .../ru-RU/tooltip_Windows_10.json | 46 +- .../ru-RU/tooltip_Windows_11.json | 28 - .../Module/Sophia.psm1 | 606 ++++++++++-------- src/Sophia_Script_for_Windows_10/Sophia.ps1 | 40 +- .../Module/Sophia.psm1 | 406 +++++++----- .../Sophia.ps1 | 24 +- .../Module/Sophia.psm1 | 430 +++++++------ .../Sophia.ps1 | 24 +- .../Module/Sophia.psm1 | 606 ++++++++++-------- .../Sophia.ps1 | 40 +- .../Module/Sophia.psm1 | 424 ++++++------ src/Sophia_Script_for_Windows_11/Sophia.ps1 | 20 +- .../Module/Sophia.psm1 | 385 +++++------ .../Sophia.ps1 | 20 +- .../Module/Sophia.psm1 | 410 ++++++------ .../Sophia.ps1 | 20 +- 24 files changed, 1915 insertions(+), 1936 deletions(-) diff --git a/Wrapper/Config/config_Windows_10.json b/Wrapper/Config/config_Windows_10.json index 754c07409..dd17a86f7 100644 --- a/Wrapper/Config/config_Windows_10.json +++ b/Wrapper/Config/config_Windows_10.json @@ -572,22 +572,6 @@ "Preset": "Zero", "WindowsDefault": "One" }, - { - "Region": "UI & Personalization", - "Control": "cmb", - "Required": "false", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide" - }, - "One": { - "Tag": "Show" - } - }, - "Preset": "Zero", - "WindowsDefault": "One" - }, { "Region": "UI & Personalization", "Control": "cmb", @@ -700,6 +684,25 @@ "Preset": "Zero", "WindowsDefault": "One" }, + { + "Region": "UI & Personalization", + "Control": "cmb", + "Required": "false", + "Function": "TaskbarCombine", + "Arg": { + "Zero": { + "Tag": "Always" + }, + "One": { + "Tag": "Full" + }, + "Two": { + "Tag": "Never" + } + }, + "Preset": "Zero", + "WindowsDefault": "Zero" + }, { "Region": "UI & Personalization", "Control": "chk", @@ -1106,22 +1109,6 @@ "Preset": "Zero", "WindowsDefault": "One" }, - { - "Region": "System", - "Control": "cmb", - "Required": "false", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable" - }, - "One": { - "Tag": "Disable" - } - }, - "Preset": "Zero", - "WindowsDefault": "One" - }, { "Region": "System", "Control": "cmb", @@ -2228,6 +2215,22 @@ "Preset": "", "WindowsDefault": "One" }, + { + "Region": "Context menu", + "Control": "cmb", + "Required": "false", + "Function": "ImagesEditContext", + "Arg": { + "Zero": { + "Tag": "Hide" + }, + "One": { + "Tag": "Show" + } + }, + "Preset": "Zero", + "WindowsDefault": "One" + }, { "Region": "Context menu", "Control": "cmb", diff --git a/Wrapper/Config/config_Windows_10_LTSC.json b/Wrapper/Config/config_Windows_10_LTSC.json index 517875d21..30cb23951 100644 --- a/Wrapper/Config/config_Windows_10_LTSC.json +++ b/Wrapper/Config/config_Windows_10_LTSC.json @@ -608,6 +608,25 @@ "LTSC2019": "true", "LTSC2021": "true" }, + { + "Region": "UI & Personalization", + "Control": "cmb", + "Required": "false", + "Function": "TaskbarCombine", + "Arg": { + "Zero": { + "Tag": "Always" + }, + "One": { + "Tag": "Full" + }, + "Two": { + "Tag": "Never" + } + }, + "Preset": "Zero", + "WindowsDefault": "Zero" + }, { "Region": "UI & Personalization", "Control": "cmb", @@ -986,24 +1005,6 @@ "LTSC2019": "true", "LTSC2021": "true" }, - { - "Region": "System", - "Control": "cmb", - "Required": "false", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable" - }, - "One": { - "Tag": "Disable" - } - }, - "Preset": "Zero", - "WindowsDefault": "One", - "LTSC2019": "true", - "LTSC2021": "true" - }, { "Region": "System", "Control": "cmb", diff --git a/Wrapper/Config/config_Windows_11.json b/Wrapper/Config/config_Windows_11.json index 0f0205686..ecb6c78c9 100644 --- a/Wrapper/Config/config_Windows_11.json +++ b/Wrapper/Config/config_Windows_11.json @@ -591,22 +591,6 @@ "Preset": "Zero", "WindowsDefault": "One" }, - { - "Region": "UI & Personalization", - "Control": "cmb", - "Required": "false", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide" - }, - "One": { - "Tag": "Show" - } - }, - "Preset": "Zero", - "WindowsDefault": "One" - }, { "Region": "UI & Personalization", "Control": "cmb", @@ -1029,22 +1013,6 @@ "Preset": "Zero", "WindowsDefault": "One" }, - { - "Region": "System", - "Control": "cmb", - "Required": "false", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable" - }, - "One": { - "Tag": "Disable" - } - }, - "Preset": "Zero", - "WindowsDefault": "One" - }, { "Region": "System", "Control": "cmb", diff --git a/Wrapper/Config/config_Windows_11_LTSC.json b/Wrapper/Config/config_Windows_11_LTSC.json index 92dd40ed0..a852e19e3 100644 --- a/Wrapper/Config/config_Windows_11_LTSC.json +++ b/Wrapper/Config/config_Windows_11_LTSC.json @@ -611,23 +611,6 @@ "WindowsDefault": "One", "LTSC2024": "true" }, - { - "Region": "UI & Personalization", - "Control": "cmb", - "Required": "false", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide" - }, - "One": { - "Tag": "Show" - } - }, - "Preset": "Zero", - "WindowsDefault": "One", - "LTSC2024": "true" - }, { "Region": "UI & Personalization", "Control": "cmb", @@ -1045,23 +1028,6 @@ "WindowsDefault": "One", "LTSC2024": "true" }, - { - "Region": "System", - "Control": "cmb", - "Required": "false", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable" - }, - "One": { - "Tag": "Disable" - } - }, - "Preset": "Zero", - "WindowsDefault": "One", - "LTSC2024": "true" - }, { "Region": "System", "Control": "cmb", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json index 0b9a90e29..3951d4ddb 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json +++ b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json @@ -499,20 +499,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Ausblenden der Schaltfläche Copilot in der Taskleiste." - }, - "One": { - "Tag": "Show", - "ToolTip": "Zeigen Sie die Schaltfläche Copilot in der Taskleiste an (Standardeinstellung)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -611,6 +597,24 @@ } } }, + { + "Region": "UI & Personalization", + "Function": "TaskbarCombine", + "Arg": { + "Zero": { + "Tag": "Always", + "ToolTip": "Kombinieren Sie Schaltflächen in der Taskleiste und blenden Sie Beschriftungen immer aus (Standardeinstellung)." + }, + "One": { + "Tag": "Full", + "ToolTip": "Taskleistenschaltflächen zusammenfassen und Beschriftungen ausblenden, wenn die Taskleiste voll ist.." + }, + "Two": { + "Tag": "Never", + "ToolTip": "Kombinieren Sie die Schaltflächen der Taskleiste und blenden Sie die Beschriftungen nicht aus.." + } + } + }, { "Region": "UI & Personalization", "Function": "UnpinTaskbarShortcuts -Shortcuts", @@ -970,20 +974,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Aktiviert den Zugriff auf zugeordnete Laufwerke von einer Anwendung, die mit erweiterten Berechtigungen und aktiviertem Admin-Genehmigungsmodus ausgeführt wird." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Deaktiviert den Zugriff auf zugeordnete Laufwerke von Anwendungen, die mit erweiterten Berechtigungen und aktiviertem Admin-Genehmigungsmodus ausgeführt werden (Standardeinstellung)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json index 33b8455ce..b280affcf 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json +++ b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json @@ -517,20 +517,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Ausblenden der Schaltfläche Copilot in der Taskleiste." - }, - "One": { - "Tag": "Show", - "ToolTip": "Zeigen Sie die Schaltfläche Copilot in der Taskleiste an (Standardeinstellung)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -918,20 +904,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Aktiviert den Zugriff auf zugeordnete Laufwerke von einer Anwendung, die mit erweiterten Berechtigungen und aktiviertem Admin-Genehmigungsmodus ausgeführt wird." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Deaktiviert den Zugriff auf zugeordnete Laufwerke von Anwendungen, die mit erweiterten Berechtigungen und aktiviertem Admin-Genehmigungsmodus ausgeführt werden (Standardeinstellung)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_10.json b/Wrapper/Localizations/en-US/tooltip_Windows_10.json index 07e9b2dc5..200324fa3 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_10.json +++ b/Wrapper/Localizations/en-US/tooltip_Windows_10.json @@ -347,11 +347,11 @@ "Arg": { "Zero": { "Tag": "Expanded", - "ToolTip": "Expand the File Explorer ribbon." + "ToolTip": "Expand File Explorer ribbon." }, "One": { "Tag": "Minimized", - "ToolTip": "Minimize the File Explorer ribbon (default value)." + "ToolTip": "Minimize File Explorer ribbon (default value)." } } }, @@ -499,20 +499,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Hide Copilot button on the taskbar." - }, - "One": { - "Tag": "Show", - "ToolTip": "Show Copilot button on the taskbar (default value)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -611,6 +597,20 @@ } } }, + { + "Region": "UI & Personalization", + "Function": "SecondsInSystemClock", + "Arg": { + "Zero": { + "Tag": "Show", + "ToolTip": "Show seconds on the taskbar clock." + }, + "One": { + "Tag": "Hide", + "ToolTip": "Hide seconds on the taskbar clock (default value)." + } + } + }, { "Region": "UI & Personalization", "Function": "UnpinTaskbarShortcuts -Shortcuts", @@ -970,20 +970,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_11.json b/Wrapper/Localizations/en-US/tooltip_Windows_11.json index 87defb701..b88461fd6 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_11.json +++ b/Wrapper/Localizations/en-US/tooltip_Windows_11.json @@ -361,11 +361,11 @@ "Arg": { "Zero": { "Tag": "Disable", - "ToolTip": "Disable the File Explorer compact mode (default value)." + "ToolTip": "Disable File Explorer compact mode (default value)." }, "One": { "Tag": "Enable", - "ToolTip": "Enable the File Explorer compact mode." + "ToolTip": "Enable File Explorer compact mode." } } }, @@ -517,20 +517,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Hide Copilot button on the taskbar." - }, - "One": { - "Tag": "Show", - "ToolTip": "Show Copilot button on the taskbar (default value)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -918,20 +904,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json index 3d5b2f865..7f63b9f7e 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json +++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json @@ -499,20 +499,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Скрыть кнопку Copilot с панели задач." - }, - "One": { - "Tag": "Show", - "ToolTip": "Отобразить кнопку Copilot на панели задач (значение по умолчанию)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -611,6 +597,24 @@ } } }, + { + "Region": "UI & Personalization", + "Function": "TaskbarCombine", + "Arg": { + "Zero": { + "Tag": "Always", + "ToolTip": "Объединить кнопки панели задач и всегда скрывать метки (значение по умолчанию)." + }, + "One": { + "Tag": "Full", + "ToolTip": "Объединить кнопки панели задач и скрывать метки при переполнении панели задач." + }, + "Two": { + "Tag": "Never", + "ToolTip": "Объединить кнопки панели задач и никогда не скрывать метки." + } + } + }, { "Region": "UI & Personalization", "Function": "UnpinTaskbarShortcuts -Shortcuts", @@ -970,20 +974,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json index cfcbd42a3..2a5fe21a2 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json +++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json @@ -517,20 +517,6 @@ } } }, - { - "Region": "UI & Personalization", - "Function": "CopilotButton", - "Arg": { - "Zero": { - "Tag": "Hide", - "ToolTip": "Скрыть кнопку Copilot с панели задач." - }, - "One": { - "Tag": "Show", - "ToolTip": "Отобразить кнопку Copilot на панели задач (значение по умолчанию)." - } - } - }, { "Region": "UI & Personalization", "Function": "TaskViewButton", @@ -918,20 +904,6 @@ } } }, - { - "Region": "System", - "Function": "MappedDrivesAppElevatedAccess", - "Arg": { - "Zero": { - "Tag": "Enable", - "ToolTip": "Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами." - }, - "One": { - "Tag": "Disable", - "ToolTip": "Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию)." - } - } - }, { "Region": "System", "Function": "DeliveryOptimization", diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 30c553343..9626f1e78 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -1330,8 +1330,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1411,11 +1410,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1884,22 +1883,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2159,22 +2155,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2796,22 +2789,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2819,13 +2809,13 @@ function FileTransferDialog <# .SYNOPSIS - The File Explorer ribbon + File Explorer ribbon .PARAMETER Expanded - Expand the File Explorer ribbon + Expand File Explorer ribbon .PARAMETER Minimized - Minimize the File Explorer ribbon + Minimize File Explorer ribbon .EXAMPLE FileExplorerRibbon -Expanded @@ -2855,6 +2845,11 @@ function FileExplorerRibbon $Minimized ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Expanded" @@ -2914,6 +2909,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -3202,6 +3202,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3317,6 +3322,18 @@ function TaskbarSearch $SearchBox ) + # Checking whether small taskbar buttons enabled + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) + if ($TaskbarSmallIcons -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3372,12 +3389,30 @@ function SearchHighlights $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds\DSB -Name ShowDynamicContent -PropertyType DWord -Value 0 -Force - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force + # Checking whether "Web search in Windows Search" was disabled. It also disable Search Highlights automatically + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) + if ($DisableSearchBoxSuggestions -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + else + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds\DSB -Name ShowDynamicContent -PropertyType DWord -Value 0 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force + } } "Show" { @@ -3425,6 +3460,10 @@ function CortanaButton $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name AllowCortana -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name AllowCortana -Type CLEAR + if (-not (Get-AppxPackage -Name Microsoft.549981C3F5F10)) { Write-Information -MessageData "" -InformationAction Continue @@ -3447,57 +3486,6 @@ function CortanaButton } } -<# - .SYNOPSIS - Copilot button on the taskbar - - .PARAMETER Hide - Hide Copilot button on the taskbar - - .PARAMETER Show - Show Copilot button on the taskbar - - .EXAMPLE - CopilotButton -Hide - - .EXAMPLE - CopilotButton -Show - - .NOTES - Current user -#> -function CopilotButton -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Hide" - )] - [switch] - $Hide, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Show" - )] - [switch] - $Show - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Hide" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 0 -Force - } - "Show" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 1 -Force - } - } -} - <# .SYNOPSIS Task view button on the taskbar @@ -3590,7 +3578,11 @@ function NewsInterests $Enable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name EnableFeeds -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests" -Name value -Force -ErrorAction Ignore + + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -3599,10 +3591,6 @@ function NewsInterests return } - # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name EnableFeeds -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests" -Name value -Force -ErrorAction Ignore - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() $MachineId = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SQMClient", "MachineId", $null) if (-not $MachineId) @@ -3649,9 +3637,9 @@ public static extern int HashData(byte[] pbData, int cbData, byte[] piet, int ou # Get value to save in EnShellFeedsTaskbarViewMode key $DWordData = [System.BitConverter]::ToUInt32($bytesOut,0) - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 2 -Force} + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 2 -Force} # We need to use here an approach with "-Command & {}" as there's a variable inside - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" } "Enable" { @@ -3667,9 +3655,9 @@ public static extern int HashData(byte[] pbData, int cbData, byte[] piet, int ou # Get value to save in EnShellFeedsTaskbarViewMode key $DWordData = [System.BitConverter]::ToUInt32($bytesOut,0) - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 0 -Force} + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 0 -Force} # We need to use here an approach with "-Command & {}" as there's a variable inside - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" } } @@ -3714,6 +3702,11 @@ function PeopleTaskbar $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3773,6 +3766,11 @@ function MeetNow $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3830,6 +3828,10 @@ function WindowsInkWorkspace $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace -Name AllowWindowsInkWorkspace -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3881,6 +3883,11 @@ function NotificationAreaIcons $Hide ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Show" @@ -3945,6 +3952,79 @@ function SecondsInSystemClock } } +<# + .SYNOPSIS + Combine taskbar buttons and hide labels + + .PARAMETER Always + Combine taskbar buttons and always hide labels + + .PARAMETER Full + Combine taskbar buttons and hide labels when taskbar is full + + .PARAMETER Never + Combine taskbar buttons and never hide labels + + .EXAMPLE + TaskbarCombine -Always + + .EXAMPLE + TaskbarCombine -Full + + .EXAMPLE + TaskbarCombine -Never + + .NOTES + Current user +#> +function TaskbarCombine +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Always" + )] + [switch] + $Always, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Full" + )] + [switch] + $Full, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Never" + )] + [switch] + $Never + ) + + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + + switch ($PSCmdlet.ParameterSetName) + { + "Always" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force + } + "Full" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force + } + "Never" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force + } + } +} + <# .SYNOPSIS Unpin shortcuts from the taskbar @@ -4067,32 +4147,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -4248,10 +4325,13 @@ function NewAppInstalledNotification New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type DWORD -Value 1 } "Show" { Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type CLEAR } } } @@ -4294,6 +4374,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4470,6 +4554,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4627,6 +4713,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -5033,7 +5124,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -5203,12 +5294,12 @@ public static bool MarkFileDelete (string sourcefile) # Getting the OneDrive folder path and replacing quotes if exist $OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', "" - # Do not restart the File Explorer process automatically if it stops in order to unload libraries + # Do not restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force # Kill all explorer instances in case "launch folder windows in a separate process" enabled Get-Process -Name explorer | Stop-Process -Force Start-Sleep -Seconds 3 - # Restart the File Explorer process automatically if it stops in order to unload libraries + # Restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force # Attempt to unregister FileSyncShell64.dll and remove @@ -5372,22 +5463,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -5716,57 +5804,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -6388,19 +6425,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -6452,18 +6499,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -9072,7 +9107,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -9951,6 +9986,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9976,6 +10012,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10069,6 +10106,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10126,6 +10164,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10261,7 +10300,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -10270,6 +10309,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -10278,44 +10322,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -10330,6 +10362,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -10645,19 +10682,25 @@ function RecentlyAddedApps $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer)) + if (-not (Test-Path -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer)) { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force + New-Item -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Force } - New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type DWORD -Value 1 } "Show" { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type CLEAR } } } @@ -11669,22 +11712,19 @@ function CortanaAutostart return } + if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) + { + New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 1 -Force } "Enable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 2 -Force } } @@ -12057,14 +12097,18 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -12492,14 +12536,18 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -12806,14 +12854,18 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -13197,7 +13249,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -14269,6 +14321,66 @@ function EditWithPaint3DContext } } +<# + .SYNOPSIS + The "Edit" item in the images context menu + + .PARAMETER Hide + Hide the "Edit" item from the images context menu + + .PARAMETER Show + Show the "Edit" item in the images context menu + + .EXAMPLE + ImagesEditContext -Hide + + .EXAMPLE + ImagesEditContext -Show + + .NOTES + Current user +#> +function ImagesEditContext +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Hide" + )] + [switch] + $Hide, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Show" + )] + [switch] + $Show + ) + + if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -ne "Installed") + { + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" + { + if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit)) + { + New-Item -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Force + } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The "Print" item in the .bat and .cmd context menu @@ -14486,24 +14598,12 @@ function BitmapImageNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -14577,24 +14677,12 @@ function RichTextDocumentNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -14752,7 +14840,7 @@ function UseStoreOpenWith ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR switch ($PSCmdlet.ParameterSetName) @@ -15078,11 +15166,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index d3ae53c2d..aa35ae09e 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1 @@ -350,11 +350,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Expand the File Explorer ribbon +# Expand File Explorer ribbon # Развернуть ленту проводника FileExplorerRibbon -Expanded -# Minimize the File Explorer ribbon (default value) +# Minimize File Explorer ribbon (default value) # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized @@ -442,14 +442,6 @@ CortanaButton -Hide # Показать кнопку Кортаны на панели задач (значение по умолчанию) # CortanaButton -Show -# Hide Copilot button on the taskbar -# Скрыть кнопку Copilot с панели задач -CopilotButton -Hide - -# Show Copilot button on the taskbar (default value) -# Отобразить кнопку Copilot на панели задач (значение по умолчанию) -# CopilotButton -Show - # Hide the Task View button on the taskbar # Скрыть кнопку Просмотра задач TaskViewButton -Hide @@ -506,6 +498,18 @@ SecondsInSystemClock -Show # Скрыть секунды в системных часах на панели задач (значение по умолчанию) # SecondsInSystemClock -Hide +# Combine taskbar buttons and always hide labels (default value) +# Объединить кнопки панели задач и всегда скрывать метки (значение по умолчанию) +TaskbarCombine -Always + +# Combine taskbar buttons and hide labels when taskbar is full +# Объединить кнопки панели задач и скрывать метки при переполнении панели задач +# TaskbarCombine -Full + +# Combine taskbar buttons and never hide labels +# Объединить кнопки панели задач и никогда не скрывать метки +# TaskbarCombine -Never + # Unpin the "Microsoft Edge", "Microsoft Store", or "Mail" shortcuts from the taskbar # Открепить ярлыки "Microsoft Edge", "Microsoft Store" или "Почта" от панели задач UnpinTaskbarShortcuts -Shortcuts Edge, Store, Mail @@ -704,14 +708,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable @@ -1376,6 +1372,14 @@ EditWithPaint3DContext -Hide # Отобразить пункт "Изменить с помощью Paint 3D" в контекстном меню медиа-файлов (значение по умолчанию) # EditWithPaint3DContext -Show +# Hide the "Edit" item from the images context menu +# Скрыть пункт "Изменить" из контекстного меню изображений +ImagesEditContext -Hide + +# Show the "Edit" item in images context menu (default value) +# Отобразить пункт "Изменить" в контекстном меню изображений (значение по умолчанию) +# ImagesEditContext -Show + # Hide the "Print" item from the .bat and .cmd context menu # Скрыть пункт "Печать" из контекстного меню .bat и .cmd файлов PrintCMDContext -Hide diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index 95878d786..15f9407c6 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -684,6 +684,7 @@ public extern static string BrandingFormatString(string sFormat); exit } + # Detect Windows build version switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber) { {$_ -ne 17763} @@ -1272,8 +1273,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1350,11 +1350,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1823,22 +1823,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2245,22 +2242,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2268,13 +2262,13 @@ function FileTransferDialog <# .SYNOPSIS - The File Explorer ribbon + File Explorer ribbon .PARAMETER Expanded - Expand the File Explorer ribbon + Expand File Explorer ribbon .PARAMETER Minimized - Minimize the File Explorer ribbon + Minimize File Explorer ribbon .EXAMPLE FileExplorerRibbon -Expanded @@ -2304,6 +2298,11 @@ function FileExplorerRibbon $Minimized ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Expanded" @@ -2363,6 +2362,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -2651,6 +2655,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -2766,6 +2775,18 @@ function TaskbarSearch $SearchBox ) + # Checking whether small taskbar buttons enabled + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) + if ($TaskbarSmallIcons -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -2872,6 +2893,11 @@ function PeopleTaskbar $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -2931,6 +2957,11 @@ function NotificationAreaIcons $Hide ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Show" @@ -2995,6 +3026,79 @@ function SecondsInSystemClock } } +<# + .SYNOPSIS + Combine taskbar buttons and hide labels + + .PARAMETER Always + Combine taskbar buttons and always hide labels + + .PARAMETER Full + Combine taskbar buttons and hide labels when taskbar is full + + .PARAMETER Never + Combine taskbar buttons and never hide labels + + .EXAMPLE + TaskbarCombine -Always + + .EXAMPLE + TaskbarCombine -Full + + .EXAMPLE + TaskbarCombine -Never + + .NOTES + Current user +#> +function TaskbarCombine +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Always" + )] + [switch] + $Always, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Full" + )] + [switch] + $Full, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Never" + )] + [switch] + $Never + ) + + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + + switch ($PSCmdlet.ParameterSetName) + { + "Always" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force + } + "Full" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force + } + "Never" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force + } + } +} + <# .SYNOPSIS The Control Panel icons view @@ -3046,32 +3150,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -3176,10 +3277,13 @@ function NewAppInstalledNotification New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type DWORD -Value 1 } "Show" { Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type CLEAR } } } @@ -3222,6 +3326,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3398,6 +3506,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3910,7 +4020,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -3960,22 +4070,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -4304,57 +4411,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -4963,19 +5019,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -5027,18 +5093,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -7297,7 +7351,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -8124,6 +8178,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8149,6 +8204,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8242,6 +8298,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8299,6 +8356,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8434,7 +8492,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -8443,6 +8501,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -8451,44 +8514,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -8503,6 +8554,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -8648,19 +8704,25 @@ function RecentlyAddedApps $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer)) + if (-not (Test-Path -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer)) { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force + New-Item -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Force } - New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type DWORD -Value 1 } "Show" { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type CLEAR } } } @@ -8828,14 +8890,18 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -9263,14 +9329,18 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -9577,14 +9647,18 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -9968,7 +10042,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -11072,24 +11146,12 @@ function BitmapImageNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -11163,24 +11225,12 @@ function RichTextDocumentNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -11592,11 +11642,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 index ff630db7f..5116dc2fd 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 @@ -279,11 +279,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Expand the File Explorer ribbon +# Expand File Explorer ribbon # Развернуть ленту проводника FileExplorerRibbon -Expanded -# Minimize the File Explorer ribbon (default value) +# Minimize File Explorer ribbon (default value) # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized @@ -379,6 +379,18 @@ SecondsInSystemClock -Show # Скрыть секунды в системных часах на панели задач (значение по умолчанию) # SecondsInSystemClock -Hide +# Combine taskbar buttons and always hide labels (default value) +# Объединить кнопки панели задач и всегда скрывать метки (значение по умолчанию) +TaskbarCombine -Always + +# Combine taskbar buttons and hide labels when taskbar is full +# Объединить кнопки панели задач и скрывать метки при переполнении панели задач +# TaskbarCombine -Full + +# Combine taskbar buttons and never hide labels +# Объединить кнопки панели задач и никогда не скрывать метки +# TaskbarCombine -Never + # View the Control Panel icons by large icons # Просмотр иконок Панели управления как: крупные значки ControlPanelView -LargeIcons @@ -543,14 +555,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 6fe6373e0..04dcf0079 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -684,6 +684,7 @@ public extern static string BrandingFormatString(string sFormat); exit } + # Detect Windows build version switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber) { {$_ -ne 19044} @@ -1272,8 +1273,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1350,11 +1350,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1823,22 +1823,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -1882,22 +1879,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2468,22 +2462,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2491,13 +2482,13 @@ function FileTransferDialog <# .SYNOPSIS - The File Explorer ribbon + File Explorer ribbon .PARAMETER Expanded - Expand the File Explorer ribbon + Expand File Explorer ribbon .PARAMETER Minimized - Minimize the File Explorer ribbon + Minimize File Explorer ribbon .EXAMPLE FileExplorerRibbon -Expanded @@ -2527,6 +2518,11 @@ function FileExplorerRibbon $Minimized ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Expanded" @@ -2586,6 +2582,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -2874,6 +2875,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -2989,6 +2995,18 @@ function TaskbarSearch $SearchBox ) + # Checking whether small taskbar buttons enabled + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) + if ($TaskbarSmallIcons -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3095,6 +3113,11 @@ function PeopleTaskbar $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3154,6 +3177,10 @@ function WindowsInkWorkspace $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace -Name AllowWindowsInkWorkspace -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3205,6 +3232,11 @@ function NotificationAreaIcons $Hide ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Show" @@ -3269,6 +3301,79 @@ function SecondsInSystemClock } } +<# + .SYNOPSIS + Combine taskbar buttons and hide labels + + .PARAMETER Always + Combine taskbar buttons and always hide labels + + .PARAMETER Full + Combine taskbar buttons and hide labels when taskbar is full + + .PARAMETER Never + Combine taskbar buttons and never hide labels + + .EXAMPLE + TaskbarCombine -Always + + .EXAMPLE + TaskbarCombine -Full + + .EXAMPLE + TaskbarCombine -Never + + .NOTES + Current user +#> +function TaskbarCombine +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Always" + )] + [switch] + $Always, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Full" + )] + [switch] + $Full, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Never" + )] + [switch] + $Never + ) + + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + + switch ($PSCmdlet.ParameterSetName) + { + "Always" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force + } + "Full" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force + } + "Never" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force + } + } +} + <# .SYNOPSIS The Control Panel icons view @@ -3320,32 +3425,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -3501,10 +3603,13 @@ function NewAppInstalledNotification New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type DWORD -Value 1 } "Show" { Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type CLEAR } } } @@ -3547,6 +3652,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3723,6 +3832,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3880,6 +3991,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -4286,7 +4402,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -4336,22 +4452,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -4680,57 +4793,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -5355,19 +5417,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -5419,18 +5491,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -7928,7 +7988,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -8755,6 +8815,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8780,6 +8841,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8873,6 +8935,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -8930,6 +8993,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9065,7 +9129,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -9074,6 +9138,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -9082,44 +9151,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -9134,6 +9191,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -9449,19 +9511,25 @@ function RecentlyAddedApps $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer)) + if (-not (Test-Path -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer)) { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force + New-Item -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Force } - New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type DWORD -Value 1 } "Show" { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type CLEAR } } } @@ -9943,14 +10011,18 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -10378,14 +10450,18 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -10692,14 +10768,18 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -11083,7 +11163,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -12184,7 +12264,7 @@ function ImagesEditContext $Show ) - if (-not ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed")) + if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -ne "Installed") { return } @@ -12423,24 +12503,12 @@ function BitmapImageNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -12514,24 +12582,12 @@ function RichTextDocumentNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -12943,11 +12999,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 index 9ddeb4bc1..98a1a909f 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 @@ -303,11 +303,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Expand the File Explorer ribbon +# Expand File Explorer ribbon # Развернуть ленту проводника FileExplorerRibbon -Expanded -# Minimize the File Explorer ribbon (default value) +# Minimize File Explorer ribbon (default value) # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized @@ -419,6 +419,18 @@ SecondsInSystemClock -Show # Скрыть секунды в системных часах на панели задач (значение по умолчанию) # SecondsInSystemClock -Hide +# Combine taskbar buttons and always hide labels (default value) +# Объединить кнопки панели задач и всегда скрывать метки (значение по умолчанию) +TaskbarCombine -Always + +# Combine taskbar buttons and hide labels when taskbar is full +# Объединить кнопки панели задач и скрывать метки при переполнении панели задач +# TaskbarCombine -Full + +# Combine taskbar buttons and never hide labels +# Объединить кнопки панели задач и никогда не скрывать метки +# TaskbarCombine -Never + # View the Control Panel icons by large icons # Просмотр иконок Панели управления как: крупные значки ControlPanelView -LargeIcons @@ -599,14 +611,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index 0057a6d81..472cfd251 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -1348,8 +1348,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1429,11 +1428,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1902,22 +1901,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2177,22 +2173,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2814,22 +2807,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2837,13 +2827,13 @@ function FileTransferDialog <# .SYNOPSIS - The File Explorer ribbon + File Explorer ribbon .PARAMETER Expanded - Expand the File Explorer ribbon + Expand File Explorer ribbon .PARAMETER Minimized - Minimize the File Explorer ribbon + Minimize File Explorer ribbon .EXAMPLE FileExplorerRibbon -Expanded @@ -2873,6 +2863,11 @@ function FileExplorerRibbon $Minimized ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ExplorerRibbonStartsMinimized -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Expanded" @@ -2932,6 +2927,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -3220,6 +3220,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3335,6 +3340,18 @@ function TaskbarSearch $SearchBox ) + # Checking whether small taskbar buttons enabled + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $TaskbarSmallIcons = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", $null)) + if ($TaskbarSmallIcons -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3390,12 +3407,30 @@ function SearchHighlights $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds\DSB -Name ShowDynamicContent -PropertyType DWord -Value 0 -Force - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force + # Checking whether "Web search in Windows Search" was disabled. It also disable Search Highlights automatically + # Due to "Set-StrictMode -Version Latest" we have to use GetValue() + $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) + if ($DisableSearchBoxSuggestions -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } + else + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds\DSB -Name ShowDynamicContent -PropertyType DWord -Value 0 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force + } } "Show" { @@ -3443,6 +3478,10 @@ function CortanaButton $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name AllowCortana -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name AllowCortana -Type CLEAR + if (-not (Get-AppxPackage -Name Microsoft.549981C3F5F10)) { Write-Information -MessageData "" -InformationAction Continue @@ -3465,57 +3504,6 @@ function CortanaButton } } -<# - .SYNOPSIS - Copilot button on the taskbar - - .PARAMETER Hide - Hide Copilot button on the taskbar - - .PARAMETER Show - Show Copilot button on the taskbar - - .EXAMPLE - CopilotButton -Hide - - .EXAMPLE - CopilotButton -Show - - .NOTES - Current user -#> -function CopilotButton -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Hide" - )] - [switch] - $Hide, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Show" - )] - [switch] - $Show - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Hide" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 0 -Force - } - "Show" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 1 -Force - } - } -} - <# .SYNOPSIS Task view button on the taskbar @@ -3608,7 +3596,11 @@ function NewsInterests $Enable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name EnableFeeds -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests" -Name value -Force -ErrorAction Ignore + + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -3617,10 +3609,6 @@ function NewsInterests return } - # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name EnableFeeds -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests" -Name value -Force -ErrorAction Ignore - # Due to "Set-StrictMode -Version Latest" we have to use GetValue() $MachineId = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SQMClient", "MachineId", $null) if (-not $MachineId) @@ -3667,9 +3655,9 @@ public static extern int HashData(byte[] pbData, int cbData, byte[] piet, int ou # Get value to save in EnShellFeedsTaskbarViewMode key $DWordData = [System.BitConverter]::ToUInt32($bytesOut,0) - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 2 -Force} + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 2 -Force} # We need to use here an approach with "-Command & {}" as there's a variable inside - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" } "Enable" { @@ -3685,9 +3673,9 @@ public static extern int HashData(byte[] pbData, int cbData, byte[] piet, int ou # Get value to save in EnShellFeedsTaskbarViewMode key $DWordData = [System.BitConverter]::ToUInt32($bytesOut,0) - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 0 -Force} + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 0 -Force} # We need to use here an approach with "-Command & {}" as there's a variable inside - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" + & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Command "& {New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds -Name EnShellFeedsTaskbarViewMode -PropertyType DWord -Value $DWordData -Force}" } } @@ -3732,6 +3720,11 @@ function PeopleTaskbar $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HidePeopleBar -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3791,6 +3784,11 @@ function MeetNow $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3848,6 +3846,10 @@ function WindowsInkWorkspace $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace -Name AllowWindowsInkWorkspace -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAMeetNow -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3899,6 +3901,11 @@ function NotificationAreaIcons $Hide ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoAutoTrayNotify -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Show" @@ -3963,6 +3970,79 @@ function SecondsInSystemClock } } +<# + .SYNOPSIS + Combine taskbar buttons and hide labels + + .PARAMETER Always + Combine taskbar buttons and always hide labels + + .PARAMETER Full + Combine taskbar buttons and hide labels when taskbar is full + + .PARAMETER Never + Combine taskbar buttons and never hide labels + + .EXAMPLE + TaskbarCombine -Always + + .EXAMPLE + TaskbarCombine -Full + + .EXAMPLE + TaskbarCombine -Never + + .NOTES + Current user +#> +function TaskbarCombine +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Always" + )] + [switch] + $Always, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Full" + )] + [switch] + $Full, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Never" + )] + [switch] + $Never + ) + + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + + switch ($PSCmdlet.ParameterSetName) + { + "Always" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force + } + "Full" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force + } + "Never" + { + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force + } + } +} + <# .SYNOPSIS Unpin shortcuts from the taskbar @@ -4085,32 +4165,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -4266,10 +4343,13 @@ function NewAppInstalledNotification New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type DWORD -Value 1 } "Show" { Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoNewAppAlert -Type CLEAR } } } @@ -4312,6 +4392,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4488,6 +4572,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4645,6 +4731,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -5051,7 +5142,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -5223,12 +5314,12 @@ public static bool MarkFileDelete (string sourcefile) # Getting the OneDrive folder path and replacing quotes if exist $OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', "" - # Do not restart the File Explorer process automatically if it stops in order to unload libraries + # Do not restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force # Kill all explorer instances in case "launch folder windows in a separate process" enabled Get-Process -Name explorer | Stop-Process -Force Start-Sleep -Seconds 3 - # Restart the File Explorer process automatically if it stops in order to unload libraries + # Restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force # Attempt to unregister FileSyncShell64.dll and remove @@ -5392,22 +5483,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -5736,57 +5824,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -6408,19 +6445,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -6472,18 +6519,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -9092,7 +9127,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -9971,6 +10006,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9996,6 +10032,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10089,6 +10126,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10146,6 +10184,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -10281,7 +10320,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -10290,6 +10329,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -10298,44 +10342,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -10350,6 +10382,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -10665,19 +10702,25 @@ function RecentlyAddedApps $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer)) + if (-not (Test-Path -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer)) { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force + New-Item -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Force } - New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force + + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type DWORD -Value 1 } "Show" { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Type CLEAR } } } @@ -11699,22 +11742,19 @@ function CortanaAutostart return } + if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) + { + New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 1 -Force } "Enable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 2 -Force } } @@ -12087,14 +12127,18 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -12522,14 +12566,18 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -12836,14 +12884,18 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -13227,7 +13279,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -14299,6 +14351,66 @@ function EditWithPaint3DContext } } +<# + .SYNOPSIS + The "Edit" item in the images context menu + + .PARAMETER Hide + Hide the "Edit" item from the images context menu + + .PARAMETER Show + Show the "Edit" item in the images context menu + + .EXAMPLE + ImagesEditContext -Hide + + .EXAMPLE + ImagesEditContext -Show + + .NOTES + Current user +#> +function ImagesEditContext +{ + param + ( + [Parameter( + Mandatory = $true, + ParameterSetName = "Hide" + )] + [switch] + $Hide, + + [Parameter( + Mandatory = $true, + ParameterSetName = "Show" + )] + [switch] + $Show + ) + + if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -ne "Installed") + { + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" + { + if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit)) + { + New-Item -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Force + } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The "Print" item in the .bat and .cmd context menu @@ -14516,24 +14628,12 @@ function BitmapImageNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -14607,24 +14707,12 @@ function RichTextDocumentNewContext { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online } - catch [System.ComponentModel.Win32Exception] + catch [System.Runtime.InteropServices.COMException] { Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue @@ -14782,7 +14870,7 @@ function UseStoreOpenWith ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR switch ($PSCmdlet.ParameterSetName) @@ -15108,11 +15196,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 index 630d2f77e..546cb0a32 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 @@ -354,11 +354,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Expand the File Explorer ribbon +# Expand File Explorer ribbon # Развернуть ленту проводника FileExplorerRibbon -Expanded -# Minimize the File Explorer ribbon (default value) +# Minimize File Explorer ribbon (default value) # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized @@ -446,14 +446,6 @@ CortanaButton -Hide # Показать кнопку Кортаны на панели задач (значение по умолчанию) # CortanaButton -Show -# Hide Copilot button on the taskbar -# Скрыть кнопку Copilot с панели задач -CopilotButton -Hide - -# Show Copilot button on the taskbar (default value) -# Отобразить кнопку Copilot на панели задач (значение по умолчанию) -# CopilotButton -Show - # Hide the Task View button on the taskbar # Скрыть кнопку Просмотра задач TaskViewButton -Hide @@ -510,6 +502,18 @@ SecondsInSystemClock -Show # Скрыть секунды в системных часах на панели задач (значение по умолчанию) # SecondsInSystemClock -Hide +# Combine taskbar buttons and always hide labels (default value) +# Объединить кнопки панели задач и всегда скрывать метки (значение по умолчанию) +TaskbarCombine -Always + +# Combine taskbar buttons and hide labels when taskbar is full +# Объединить кнопки панели задач и скрывать метки при переполнении панели задач +# TaskbarCombine -Full + +# Combine taskbar buttons and never hide labels +# Объединить кнопки панели задач и никогда не скрывать метки +# TaskbarCombine -Never + # Unpin the "Microsoft Edge", "Microsoft Store", or "Mail" shortcuts from the taskbar # Открепить ярлыки "Microsoft Edge", "Microsoft Store" или "Почта" от панели задач UnpinTaskbarShortcuts -Shortcuts Edge, Store, Mail @@ -708,14 +712,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable @@ -1380,6 +1376,14 @@ EditWithPaint3DContext -Hide # Отобразить пункт "Изменить с помощью Paint 3D" в контекстном меню медиа-файлов (значение по умолчанию) # EditWithPaint3DContext -Show +# Hide the "Edit" item from the images context menu +# Скрыть пункт "Изменить" из контекстного меню изображений +ImagesEditContext -Hide + +# Show the "Edit" item in images context menu (default value) +# Отобразить пункт "Изменить" в контекстном меню изображений (значение по умолчанию) +# ImagesEditContext -Show + # Hide the "Print" item from the .bat and .cmd context menu # Скрыть пункт "Печать" из контекстного меню .bat и .cmd файлов PrintCMDContext -Hide diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index a6591d735..fd5c0f1a9 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -1304,8 +1304,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1385,11 +1384,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1864,22 +1863,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2139,22 +2135,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2692,10 +2685,10 @@ function OpenFileExplorerTo File Explorer mode .PARAMETER Disable - Disable the File Explorer compact mode + Disable File Explorer compact mode .PARAMETER Enable - Enable the File Explorer compact mode + Enable File Explorer compact mode .EXAMPLE FileExplorerCompactMode -Disable @@ -2878,22 +2871,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2937,6 +2927,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -2992,6 +2987,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3154,6 +3154,11 @@ function TaskbarWidgets return } + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests -Name value -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Dsh -Name AllowNewsAndInterests -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Dsh -Name AllowNewsAndInterests -Type CLEAR + # We cannot set a value to TaskbarDa, having called any of APIs, except of copying powershell.exe (or any other tricks) with a different name, due to a UCPD driver tracks all executables to block the access to the registry Copy-Item -Path "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -Destination "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Force @@ -3292,11 +3297,15 @@ function SearchHighlights $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" { - # Checking whether "Ask Copilot" and "Find results in Web" (Web) were disabled. They also disable Search Highlights automatically + # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically # Due to "Set-StrictMode -Version Latest" we have to use GetValue() $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) @@ -3315,7 +3324,7 @@ function SearchHighlights } "Show" { - # Enable "Ask Copilot" and "Find results in Web" (Web) icons in Windows Search in order to enable Search Highlights + # Enable "Ask Copilot" and "Find results in Web" icons in Windows Search in order to enable Search Highlights Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Force -ErrorAction Ignore Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Force -ErrorAction Ignore @@ -3324,57 +3333,6 @@ function SearchHighlights } } -<# - .SYNOPSIS - Copilot button on the taskbar - - .PARAMETER Hide - Hide Copilot button on the taskbar - - .PARAMETER Show - Show Copilot button on the taskbar - - .EXAMPLE - CopilotButton -Hide - - .EXAMPLE - CopilotButton -Show - - .NOTES - Current user -#> -function CopilotButton -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Hide" - )] - [switch] - $Hide, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Show" - )] - [switch] - $Show - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Hide" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 0 -Force - } - "Show" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 1 -Force - } - } -} - <# .SYNOPSIS Task view button on the taskbar @@ -3413,6 +3371,11 @@ function TaskViewButton $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3528,19 +3491,24 @@ function TaskbarCombine $Never ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Always" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 0 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force } "Full" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force } "Never" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force } } } @@ -3711,32 +3679,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -3883,6 +3848,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3985,6 +3954,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4142,6 +4113,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -4548,7 +4524,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -4718,12 +4694,12 @@ public static bool MarkFileDelete (string sourcefile) # Getting the OneDrive folder path and replacing quotes if exist $OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', "" - # Do not restart the File Explorer process automatically if it stops in order to unload libraries + # Do not restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force # Kill all explorer instances in case "launch folder windows in a separate process" enabled Get-Process -Name explorer | Stop-Process -Force Start-Sleep -Seconds 3 - # Restart the File Explorer process automatically if it stops in order to unload libraries + # Restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force # Attempt to unregister FileSyncShell64.dll and remove @@ -4887,22 +4863,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -4946,21 +4919,20 @@ function StorageSenseTempFiles $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if ((Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1") - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 04 -PropertyType DWord -Value 1 -Force - } + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if ((Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1") - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 04 -PropertyType DWord -Value 0 -Force - } + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } } @@ -5231,57 +5203,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -5900,19 +5821,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -5964,18 +5895,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -8584,7 +8503,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -9488,6 +9407,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9513,6 +9433,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9606,6 +9527,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9663,6 +9585,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9798,7 +9721,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -9807,6 +9730,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -9815,44 +9743,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -9867,6 +9783,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -10767,22 +10688,19 @@ function CortanaAutostart return } + if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) + { + New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 1 -Force } "Enable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 2 -Force } } @@ -11140,14 +11058,28 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -11575,14 +11507,28 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -11889,14 +11835,28 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -12280,7 +12240,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -13088,7 +13048,8 @@ function LocalSecurityAuthority ) # Remove all policies in order to make changes visible in UI only if it's possible - Set-Policy -Scope Computer -Path Software\Policies\Microsoft\Windows\Explorer -Name RunAsPPL -Type CLEAR + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Type CLEAR switch ($PSCmdlet.ParameterSetName) { @@ -13120,7 +13081,6 @@ function LocalSecurityAuthority "Disable" { Remove-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa -Name RunAsPPL, RunAsPPLBoot -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore } } } @@ -13574,7 +13534,7 @@ function UseStoreOpenWith ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR switch ($PSCmdlet.ParameterSetName) @@ -14061,11 +14021,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index badfbdb85..7adfd0428 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1 @@ -357,11 +357,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Disable the File Explorer compact mode (default value) +# Disable File Explorer compact mode (default value) # Отключить компактный вид проводника (значение по умолчанию) FileExplorerCompactMode -Disable -# Enable the File Explorer compact mode +# Enable File Explorer compact mode # Включить компактный вид проводника # FileExplorerCompactMode -Enable @@ -453,14 +453,6 @@ SearchHighlights -Hide # Показать главное в поиске (значение по умолчанию) # SearchHighlights -Show -# Hide Copilot button on the taskbar -# Скрыть кнопку Copilot с панели задач -CopilotButton -Hide - -# Show Copilot button on the taskbar (default value) -# Отобразить кнопку Copilot на панели задач (значение по умолчанию) -# CopilotButton -Show - # Hide the Task view button from the taskbar # Скрыть кнопку "Представление задач" с панели задач TaskViewButton -Hide @@ -679,14 +671,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 index 5fe076296..5d3da3a0b 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 @@ -1275,8 +1275,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1353,11 +1352,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1832,22 +1831,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2107,22 +2103,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2660,10 +2653,10 @@ function OpenFileExplorerTo File Explorer mode .PARAMETER Disable - Disable the File Explorer compact mode + Disable File Explorer compact mode .PARAMETER Enable - Enable the File Explorer compact mode + Enable File Explorer compact mode .EXAMPLE FileExplorerCompactMode -Disable @@ -2846,22 +2839,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2905,6 +2895,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -2960,6 +2955,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3195,11 +3195,15 @@ function SearchHighlights $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" { - # Checking whether "Ask Copilot" and "Find results in Web" (Web) were disabled. They also disable Search Highlights automatically + # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically # Due to "Set-StrictMode -Version Latest" we have to use GetValue() $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) @@ -3218,7 +3222,7 @@ function SearchHighlights } "Show" { - # Enable "Ask Copilot" and "Find results in Web" (Web) icons in Windows Search in order to enable Search Highlights + # Enable "Ask Copilot" and "Find results in Web" icons in Windows Search in order to enable Search Highlights Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Force -ErrorAction Ignore Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Force -ErrorAction Ignore @@ -3227,57 +3231,6 @@ function SearchHighlights } } -<# - .SYNOPSIS - Copilot button on the taskbar - - .PARAMETER Hide - Hide Copilot button on the taskbar - - .PARAMETER Show - Show Copilot button on the taskbar - - .EXAMPLE - CopilotButton -Hide - - .EXAMPLE - CopilotButton -Show - - .NOTES - Current user -#> -function CopilotButton -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Hide" - )] - [switch] - $Hide, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Show" - )] - [switch] - $Show - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Hide" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 0 -Force - } - "Show" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 1 -Force - } - } -} - <# .SYNOPSIS Task view button on the taskbar @@ -3316,6 +3269,11 @@ function TaskViewButton $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3431,19 +3389,24 @@ function TaskbarCombine $Never ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Always" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 0 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force } "Full" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force } "Never" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force } } } @@ -3555,32 +3518,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -3727,6 +3687,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3829,6 +3793,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -3986,6 +3952,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -4392,7 +4363,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -4500,22 +4471,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -4844,57 +4812,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -5513,19 +5430,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -5577,18 +5504,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -8197,7 +8112,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -9024,6 +8939,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9049,6 +8965,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9142,6 +9059,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9199,6 +9117,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9334,7 +9253,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -9343,6 +9262,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -9351,44 +9275,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -9403,6 +9315,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -10432,14 +10349,28 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -10867,14 +10798,28 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -11181,14 +11126,28 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -11572,7 +11531,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -12371,7 +12330,8 @@ function LocalSecurityAuthority ) # Remove all policies in order to make changes visible in UI only if it's possible - Set-Policy -Scope Computer -Path Software\Policies\Microsoft\Windows\Explorer -Name RunAsPPL -Type CLEAR + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Type CLEAR switch ($PSCmdlet.ParameterSetName) { @@ -12403,7 +12363,6 @@ function LocalSecurityAuthority "Disable" { Remove-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa -Name RunAsPPL, RunAsPPLBoot -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore } } } @@ -12979,11 +12938,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 index cb5771a7b..2e2fa7cb6 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 @@ -355,11 +355,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Disable the File Explorer compact mode (default value) +# Disable File Explorer compact mode (default value) # Отключить компактный вид проводника (значение по умолчанию) FileExplorerCompactMode -Disable -# Enable the File Explorer compact mode +# Enable File Explorer compact mode # Включить компактный вид проводника # FileExplorerCompactMode -Enable @@ -443,14 +443,6 @@ SearchHighlights -Hide # Показать главное в поиске (значение по умолчанию) # SearchHighlights -Show -# Hide Copilot button on the taskbar -# Скрыть кнопку Copilot с панели задач -CopilotButton -Hide - -# Show Copilot button on the taskbar (default value) -# Отобразить кнопку Copilot на панели задач (значение по умолчанию) -# CopilotButton -Show - # Hide the Task view button from the taskbar # Скрыть кнопку "Представление задач" с панели задач TaskViewButton -Hide @@ -659,14 +651,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index 3e835dcb0..e14183af6 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -1322,8 +1322,7 @@ function ErrorReporting ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore - Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", "HKCU:\Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR Set-Policy -Scope User -Path "Software\Policies\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Type CLEAR @@ -1403,11 +1402,11 @@ function FeedbackFrequency } New-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds -Force -ErrorAction Ignore } "Automatically" { - Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Siuf\Rules -Name PeriodInNanoSeconds, NumberOfSIUFInPeriod -Force -ErrorAction Ignore } } } @@ -1882,22 +1881,19 @@ function AdvertisingID Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force } } @@ -2157,22 +2153,19 @@ function WhatsNewInWindows $Enable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force } "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force } } @@ -2710,10 +2703,10 @@ function OpenFileExplorerTo File Explorer mode .PARAMETER Disable - Disable the File Explorer compact mode + Disable File Explorer compact mode .PARAMETER Enable - Enable the File Explorer compact mode + Enable File Explorer compact mode .EXAMPLE FileExplorerCompactMode -Disable @@ -2896,22 +2889,19 @@ function FileTransferDialog $Compact ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force + } + switch ($PSCmdlet.ParameterSetName) { "Detailed" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force } "Compact" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force } } @@ -2955,6 +2945,11 @@ function RecycleBinDeleteConfirmation $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ConfirmFileDelete -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name ConfirmFileDelete -Type CLEAR + $ShellState = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState switch ($PSCmdlet.ParameterSetName) @@ -3010,6 +3005,11 @@ function QuickAccessRecentFiles $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRecentDocsHistory -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + Set-Policy -Scope User -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoRecentDocsHistory -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3172,6 +3172,11 @@ function TaskbarWidgets return } + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests -Name value -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Dsh -Name AllowNewsAndInterests -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Dsh -Name AllowNewsAndInterests -Type CLEAR + # We cannot set a value to TaskbarDa, having called any of APIs, except of copying powershell.exe (or any other tricks) with a different name, due to a UCPD driver tracks all executables to block the access to the registry Copy-Item -Path "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -Destination "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell_temp.exe" -Force @@ -3310,11 +3315,15 @@ function SearchHighlights $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name EnableDynamicContentInWSB -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" { - # Checking whether "Ask Copilot" and "Find results in Web" (Web) were disabled. They also disable Search Highlights automatically + # Checking whether "Ask Copilot" and "Find results in Web" were disabled. They also disable Search Highlights automatically # Due to "Set-StrictMode -Version Latest" we have to use GetValue() $BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null)) $DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null)) @@ -3333,7 +3342,7 @@ function SearchHighlights } "Show" { - # Enable "Ask Copilot" and "Find results in Web" (Web) icons in Windows Search in order to enable Search Highlights + # Enable "Ask Copilot" and "Find results in Web" icons in Windows Search in order to enable Search Highlights Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Force -ErrorAction Ignore Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Force -ErrorAction Ignore @@ -3342,57 +3351,6 @@ function SearchHighlights } } -<# - .SYNOPSIS - Copilot button on the taskbar - - .PARAMETER Hide - Hide Copilot button on the taskbar - - .PARAMETER Show - Show Copilot button on the taskbar - - .EXAMPLE - CopilotButton -Hide - - .EXAMPLE - CopilotButton -Show - - .NOTES - Current user -#> -function CopilotButton -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Hide" - )] - [switch] - $Hide, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Show" - )] - [switch] - $Show - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Hide" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 0 -Force - } - "Show" - { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowCopilotButton -PropertyType DWord -Value 1 -Force - } - } -} - <# .SYNOPSIS Task view button on the taskbar @@ -3431,6 +3389,11 @@ function TaskViewButton $Show ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideTaskViewButton -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -3546,19 +3509,24 @@ function TaskbarCombine $Never ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoTaskGrouping -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Always" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 0 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force } "Full" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force } "Never" { - New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name taskbarGlomLevel -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force } } } @@ -3729,32 +3697,29 @@ function ControlPanelView $SmallIcons ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name ForceClassicControlPanel -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force + } + switch ($PSCmdlet.ParameterSetName) { "Category" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force } "LargeIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } "SmallIcons" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force } @@ -3901,6 +3866,10 @@ function FirstLogonAnimation $Enable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4003,6 +3972,8 @@ function ShortcutsSuffix $Enable ) + Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name link -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Disable" @@ -4160,6 +4131,11 @@ function AeroShaking $Disable ) + # Remove all policies in order to make changes visible in UI only if it's possible + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Software\Policies\Microsoft\Windows\Explorer -Name NoWindowMinimizingShortcuts -Type CLEAR + switch ($PSCmdlet.ParameterSetName) { "Enable" @@ -4566,7 +4542,7 @@ function NavigationPaneExpand { "Disable" { - Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore + New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 0 -Force } "Enable" { @@ -4738,12 +4714,12 @@ public static bool MarkFileDelete (string sourcefile) # Getting the OneDrive folder path and replacing quotes if exist $OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', "" - # Do not restart the File Explorer process automatically if it stops in order to unload libraries + # Do not restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force # Kill all explorer instances in case "launch folder windows in a separate process" enabled Get-Process -Name explorer | Stop-Process -Force Start-Sleep -Seconds 3 - # Restart the File Explorer process automatically if it stops in order to unload libraries + # Restart File Explorer process automatically if it stops in order to unload libraries New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force # Attempt to unregister FileSyncShell64.dll and remove @@ -4907,22 +4883,19 @@ function StorageSense $Disable ) + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force + } + switch ($PSCmdlet.ParameterSetName) { "Enable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force } "Disable" { - if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy)) - { - New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force - } New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force } } @@ -5251,57 +5224,6 @@ function AdminApprovalMode } } -<# - .SYNOPSIS - Access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Enable - Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .PARAMETER Disable - Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled - - .EXAMPLE - MappedDrivesAppElevatedAccess -Enable - - .EXAMPLE - MappedDrivesAppElevatedAccess -Disable - - .NOTES - Machine-wide -#> -function MappedDrivesAppElevatedAccess -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - switch ($PSCmdlet.ParameterSetName) - { - "Enable" - { - New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Delivery Optimization @@ -5920,19 +5842,29 @@ function WindowsCapabilities function InstallButton { - Write-Information -MessageData "" -InformationAction Continue - # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose + try + { + Write-Information -MessageData "" -InformationAction Continue + # Extract the localized "Please wait..." string from shell32.dll + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose - [void]$Window.Close() + [void]$Window.Close() - $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} - $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online + $SelectedCapabilities | ForEach-Object -Process {Write-Verbose -Message $_.DisplayName -Verbose} + $SelectedCapabilities | Where-Object -FilterScript {$_.Name -in ((Get-WindowsCapability -Online).Name)} | Add-WindowsCapability -Online - if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + if ([string]$SelectedCapabilities.Name -match "Browser.InternetExplorer") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning + } + } + catch [System.Runtime.InteropServices.COMException] { - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning + Write-Warning -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") + Write-Error -Message ($Localization.NoResponse -f "http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } } @@ -5984,18 +5916,6 @@ function WindowsCapabilities { try { - # Check the internet connection - $Parameters = @{ - Name = "dns.msftncsi.com" - Server = "1.1.1.1" - DnsOnly = $true - ErrorAction = "Stop" - } - if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255") - { - return - } - $State = "NotPresent" $ButtonContent = $Localization.Install $ButtonAdd_Click = {InstallButton} @@ -8604,7 +8524,7 @@ public static int UnloadHive(RegistryHives hive, string subKey) } New-ItemProperty -Path "HKCU:\Software\Classes\$Extension\OpenWithProgids" -Name $ProgId -PropertyType None -Value ([byte[]]@()) -Force - # Set the system ProgId to the extension parameters for the File Explorer to the possible options for the assignment, and if absent set the specified ProgId + # Set the system ProgId to the extension parameters for File Explorer to the possible options for the assignment, and if absent set the specified ProgId # Due to "Set-StrictMode -Version Latest" we have to use GetValue() if ($OrigProgID) { @@ -9508,6 +9428,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x86" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x86.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9533,6 +9454,7 @@ function InstallVCRedist Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Visual C++ Redistributable x64" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9626,6 +9548,7 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait @@ -9683,8 +9606,10 @@ function InstallDotNetRuntimes Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ".NET $LatestRelease" -Verbose + Write-Information -MessageData "" -InformationAction Continue Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait + Write-Information -MessageData "" -InformationAction Continue # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word # https://github.com/PowerShell/PowerShell/issues/21070 @@ -9818,7 +9743,7 @@ function PreventEdgeShortcutCreation $Disable ) - if (-not (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) + if (-not (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore)) { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose @@ -9827,6 +9752,11 @@ function PreventEdgeShortcutCreation return } + if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) + { + New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force + } + foreach ($Channel in $Channels) { switch ($Channel) @@ -9835,44 +9765,32 @@ function PreventEdgeShortcutCreation { if (Get-Package -Name "Microsoft Edge" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Beta { if (Get-Package -Name "Microsoft Edge Beta" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Dev { if (Get-Package -Name "Microsoft Edge Dev" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } Canary { if (Get-Package -Name "Microsoft Edge Canary" -ProviderName Programs -ErrorAction Ignore) { - if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate)) - { - New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Force - } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -PropertyType DWord -Value 0 -Force + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type DWORD -Value 3 } } } @@ -9887,6 +9805,11 @@ function PreventEdgeShortcutCreation "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" ) Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate -Name $Names -Force -ErrorAction Ignore + + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}" -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\EdgeUpdate -Name "CreateDesktopShortcut{65C35B14-6C1D-4122-AC46-7148CC9D6497}" -Type CLEAR } } @@ -10797,22 +10720,19 @@ function CortanaAutostart return } + if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) + { + New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 1 -Force } "Enable" { - if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId")) - { - New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force - } New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 2 -Force } } @@ -11170,14 +11090,28 @@ function CleanupTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore) @@ -11605,14 +11539,28 @@ function SoftwareDistributionTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore) @@ -11919,14 +11867,28 @@ function TempTask { "Register" { - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Remove registry keys if Windows Script Host is disabled - Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + + # Checking whether VBS engine is enabled + if ((Get-WindowsCapability -Online -Name VBSCRIPT*).State -ne "Installed") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -Verbose + Write-Error -Message ($Localization.Skipped -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue + + return + } # Checking if we're trying to create the task when it was already created as another user if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore) @@ -12309,7 +12271,7 @@ function PUAppsDetection "Enable" { Set-MpPreference -PUAProtection Enabled - } + } "Disable" { Set-MpPreference -PUAProtection Disabled @@ -13117,7 +13079,8 @@ function LocalSecurityAuthority ) # Remove all policies in order to make changes visible in UI only if it's possible - Set-Policy -Scope Computer -Path Software\Policies\Microsoft\Windows\Explorer -Name RunAsPPL -Type CLEAR + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Type CLEAR switch ($PSCmdlet.ParameterSetName) { @@ -13149,7 +13112,6 @@ function LocalSecurityAuthority "Disable" { Remove-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Lsa -Name RunAsPPL, RunAsPPLBoot -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name RunAsPPL -Force -ErrorAction Ignore } } } @@ -13603,7 +13565,7 @@ function UseStoreOpenWith ) # Remove all policies in order to make changes visible in UI only if it's possible - Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR switch ($PSCmdlet.ParameterSetName) @@ -14090,11 +14052,15 @@ public static void PostMessage() #region Toast notifications # Persist Sophia notifications to prevent to immediately disappear from Action Center - # Remove registry keys if notifications and Action Center are disabled - Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + # Enable notifications in Action Center + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR + Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR # Enable notifications Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore + Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type CLEAR if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 index c4a03d0ba..92008aec6 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 @@ -361,11 +361,11 @@ OpenFileExplorerTo -ThisPC # Открывать проводник для "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess -# Disable the File Explorer compact mode (default value) +# Disable File Explorer compact mode (default value) # Отключить компактный вид проводника (значение по умолчанию) FileExplorerCompactMode -Disable -# Enable the File Explorer compact mode +# Enable File Explorer compact mode # Включить компактный вид проводника # FileExplorerCompactMode -Enable @@ -457,14 +457,6 @@ SearchHighlights -Hide # Показать главное в поиске (значение по умолчанию) # SearchHighlights -Show -# Hide Copilot button on the taskbar -# Скрыть кнопку Copilot с панели задач -CopilotButton -Hide - -# Show Copilot button on the taskbar (default value) -# Отобразить кнопку Copilot на панели задач (значение по умолчанию) -# CopilotButton -Show - # Hide the Task view button from the taskbar # Скрыть кнопку "Представление задач" с панели задач TaskViewButton -Hide @@ -683,14 +675,6 @@ AdminApprovalMode -Never # Настройка уведомления об изменении параметров компьютера: уведомлять меня только при попытках приложений внести изменения в компьютер (значение по умолчанию) # AdminApprovalMode -Default -# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled -# Включить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами -MappedDrivesAppElevatedAccess -Enable - -# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled (default value) -# Выключить доступ к сетевым дискам при включенном режиме одобрения администратором при доступе из программ, запущенных с повышенными правами (значение по умолчанию) -# MappedDrivesAppElevatedAccess -Disable - # Turn off Delivery Optimization # Выключить оптимизацию доставки DeliveryOptimization -Disable