From 27394f242c300c6c02a3d6f834ed2148994028fa Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 14 Apr 2021 20:20:17 +0300 Subject: [PATCH] 14.04.2021 v5.2.1 --- Sophia/LTSC/Functions.ps1 | 74 +++++++++++++++++++++++------ Sophia/LTSC/Sophia.ps1 | 94 +++++++++++++++++++++++-------------- Sophia/LTSC/Sophia.psd1 | Bin 1768 -> 1772 bytes Sophia/LTSC/Sophia.psm1 | 95 +++++++++----------------------------- 4 files changed, 142 insertions(+), 121 deletions(-) diff --git a/Sophia/LTSC/Functions.ps1 b/Sophia/LTSC/Functions.ps1 index 83d6058f..1705ae87 100644 --- a/Sophia/LTSC/Functions.ps1 +++ b/Sophia/LTSC/Functions.ps1 @@ -2,9 +2,11 @@ .SYNOPSIS Run the specific function, using the TAB completion - Version: v5.10 - Date: 09.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.2.1 + Date: 12.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved @@ -71,7 +73,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" +$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script v5.10.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force @@ -95,25 +97,69 @@ $Parameters = @{ $Commands = (Get-Module -Name Sophia).ExportedCommands.Keys foreach ($Command in $Commands) { - $UnnecessaryParameters = @("Verbose", "Debug", "ErrorAction", "WarningAction", "InformationAction", "ErrorVariable", "WarningVariable", "InformationVariable", "OutVariable", "OutBuffer", "PipelineVariable") - $ParameterSets = ((Get-Command -Name $Command).Parameters | Where-Object -FilterScript {$_.Keys}).Keys | Where-Object -FilterScript {$_ -notin $UnnecessaryParameters} - foreach ($ParameterSet in $ParameterSets) + $ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames} + + # If module command is PinToStart + if ($Command -eq "PinToStart") + { + # Get all command arguments, excluding defaults + foreach ($ParameterSet in $ParameterSets.Name) + { + # If Argument is PinToStart + if ($ParameterSet -eq "Tiles") + { + $ValidValues = ((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues + foreach ($ValidValue in $ValidValues) + { + # "PinToStart -Tites ControlPanel" construction + # "PinToStart -Tites DevicesPrinters" construction + # "PinToStart -Tites PowerShell" construction + "PinToStart" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + # "PinToStart -Tites ControlPanel, DevicesPrinters, PowerShell" construction + "PinToStart" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + continue + } + } + + # If module command is UninstallUWPApps + if ($Command -eq "UninstallUWPApps") + { + (Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} + + # Get all command arguments, excluding defaults + foreach ($ParameterSet in $ParameterSets.Name) + { + # If Argument is ForAllUsers + if ($ParameterSet -eq "ForAllUsers") + { + # "UninstallUWPApps -ForAllUsers" construction + "UninstallUWPApps" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + continue + } + } + + foreach ($ParameterSet in $ParameterSets.Name) { # "Function -Argument" construction - $Command + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -match $wordToComplete} | ForEach-Object -Process {"`"$_`""} + $Command + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } - continue + # Get functions list without arguments to complete + Get-Command -Name $Command | Where-Object -FilterScript {$null -eq $_.Parametersets.Parameters} | Where-Object -FilterScript {$_.Name -like "*$wordToComplete*"} } - - # Get functions list without arguments to complete - (Get-Command -Name @((Get-Module -Name Sophia).ExportedCommands.Keys)) | Where-Object -FilterScript { - $_.CmdletBinding -eq $false - } | Where-Object -FilterScript {$_.Name -match $wordToComplete} } } Register-ArgumentCompleter @Parameters +Write-Information -MessageData "`n" -InformationAction Continue Write-Verbose -Message "Sophia -Functions " -Verbose Write-Verbose -Message "Sophia -Functions temp" -Verbose Write-Verbose -Message "Sophia -Functions `"DiagTrackService -Disable`", `"DiagnosticDataLevel -Minimal`", UninstallUWPApps" -Verbose +Write-Information -MessageData "`n" -InformationAction Continue +Write-Verbose -Message "UninstallUWPApps, `"PinToStart -UnpinAll`"" -Verbose diff --git a/Sophia/LTSC/Sophia.ps1 b/Sophia/LTSC/Sophia.ps1 index 09087b72..acdd2596 100644 --- a/Sophia/LTSC/Sophia.ps1 +++ b/Sophia/LTSC/Sophia.ps1 @@ -2,26 +2,31 @@ .SYNOPSIS Default preset file for "Windows 10 Sophia Script" (LTSC version) - Version: v5.2 - Date: 08.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.2.1 + Date: 14.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved .DESCRIPTION Read carefully and configure the preset file before running - Comment out function with the "#" char if you don't want it to be run - Uncomment function by removing the "#" char if you want it to be run + Comment out function with the "#" char if you don't want it to be run + Uncomment function by removing the "#" char if you want it to be run Every tweak in the preset file has its' corresponding function to restore the default settings Running the script is best done on a fresh install because running it on wrong tweaked system may result in errors occurring - To be able to call the specific function using autocompletion enter ". .\Functions.ps1" (with a dot at the beginning) - Read more in the Functions.ps1 file + To be able to call the specific function using autocompletion invoke the Functions.ps1: + . .\Functions.ps1 (with a dot at the beginning). Read more in the Functions.ps1 file .EXAMPLE Run the whole script .\Sophia.ps1 + .EXAMPLE Run the script by specifying the module functions as an argument + .\Sophia.ps1 -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", UninstallUWPApps + .NOTES Supported Windows 10 version Version: 1809 @@ -64,13 +69,40 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" +$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2.1 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2015–2021" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia +<# + .SYNOPSIS + Run the script by specifying the module functions as an argument + Запустить скрипт, указав в качестве аргумента функции модуля + + .EXAMPLE + .\Sophia.ps1 -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", UninstallUWPApps + + .NOTES + Separate functions with a comma +#> +if ($Functions) +{ + # Regardless of the functions entered as an argument, the "Checkings" function will be executed first, + # and the "Refresh" and "Errors" functions will be executed at the end + Invoke-Command -ScriptBlock {Checkings} + + foreach ($Function in $Functions) + { + Invoke-Expression -Command $Function + } + + Invoke-Command -ScriptBlock {Refresh; Errors} + + exit +} + #region Protection <# Checkings @@ -96,12 +128,12 @@ CreateRestorePoint #endregion Protection #region Privacy & Telemetry -# Disable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and block connection -# Отключить службу DiagTrack, правила брандмауэра для исходящего трафик клиента единой телеметрии и заблокировать соединение +# Disable the DiagTrack service, and block connection for the Unified Telemetry Client Outbound Traffic +# Отключить службу DiagTrack и заблокировать соединение для исходящего трафик клиента единой телеметрии DiagTrackService -Disable -# Enable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and allow connection -# Включить службу DiagTrack, правила брандмауэра для исходящего трафик клиента единой телеметрии и разрешить соединение +# Enable the DiagTrack service, and allow connection for the Unified Telemetry Client Outbound Traffic +# Включить службу DiagTrack и разрешить соединение для исходящего трафик клиента единой телеметрии # DiagTrackService -Enable # Set the OS level of diagnostic data gathering to minimum @@ -113,7 +145,7 @@ DiagnosticDataLevel -Minimal # DiagnosticDataLevel -Default # Turn off the Windows Error Reporting -# Отключить отчеты об ошибках Windows +# Отключить запись отчетов об ошибках Windows ErrorReporting -Disable # Turn on the Windows Error Reporting (default value) @@ -214,7 +246,7 @@ MergeConflicts -Show # Открывать проводник для: "Этот компьютер" OpenFileExplorerTo -ThisPC -# Open File Explorer to: "Quick access" (default value) +# Open File Explorer to: Quick access (default value) # Открывать проводник для: "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess @@ -247,15 +279,15 @@ SecondsInSystemClock -Show SnapAssist -Disable # When I snap a window, show what I can snap next to it (default value) -# При прикреплении окна не показывать/показывать, что можно прикрепить рядом с ним (значение по умолчанию) +# При прикреплении окна показывать, что можно прикрепить рядом с ним (значение по умолчанию) # SnapAssist -Enable -# Always open the file transfer dialog box in the detailed mode -# Всегда открывать диалоговое окно передачи файлов в развернутом виде +# Show the file transfer dialog box in the detailed mode +# Отображать диалоговое окно передачи файлов в развернутом виде FileTransferDialog -Detailed -# Always open the file transfer dialog box in the compact mode (default value) -# Всегда открывать диалоговое окно передачи файлов в свернутом виде (значение по умолчанию) +# Show the file transfer dialog box in the compact mode (default value) +# Отображать диалоговое окно передачи файлов в свернутом виде (значение по умолчанию) # FileTransferDialog -Compact # Expand the File Explorer ribbon @@ -266,28 +298,28 @@ FileExplorerRibbon -Expanded # Свернуть ленту проводника (значение по умолчанию) # FileExplorerRibbon -Minimized -# Display the recycle bin files delete confirmation +# Display the recycle bin files delete confirmation dialog # Запрашивать подтверждение на удаление файлов в корзину RecycleBinDeleteConfirmation -Enable -# Do not display the recycle bin files delete confirmation (default value) +# Do not display the recycle bin files delete confirmation dialog (default value) # Не запрашивать подтверждение на удаление файлов в корзину (значение по умолчанию) # RecycleBinDeleteConfirmation -Disable -# Hide the "3D Objects" folder in "This PC" and "Quick access" +# Hide the "3D Objects" folder in "This PC" and Quick access # Скрыть папку "Объемные объекты" в "Этот компьютер" и панели быстрого доступа 3DObjects -Hide -# Show the "3D Objects" folder in "This PC" and "Quick access" (default value) +# Show the "3D Objects" folder in "This PC" and Quick access (default value) # Отобразить папку "Объемные объекты" в "Этот компьютер" и панели быстрого доступа (значение по умолчанию) # 3DObjects -Show -# Hide frequently used folders in "Quick access" +# Hide frequently used folders in Quick access # Скрыть недавно используемые папки на панели быстрого доступа QuickAccessFrequentFolders -Hide -# Show frequently used folders in "Quick access" (default value) -# Показать недавно используемые папки на панели быстрого доступа (значение по умолчанию) +# Show frequently used folders in Quick access (default value) +# Показать часто используемые папки на панели быстрого доступа (значение по умолчанию) # QuickAccessFrequentFolders -Show # Do not show recently used files in Quick access @@ -323,7 +355,7 @@ TrayIcons -Show ControlPanelView -LargeIcons # View the Control Panel icons by: category (default value) -# Просмотр значки Панели управления как "категория" (значение по умолчанию) +# Просмотр значки Панели управления как: категория (значение по умолчанию) # ControlPanelView -Category # Set the Windows mode color scheme to the dark @@ -334,14 +366,6 @@ WindowsColorScheme -Dark # Установить режим цвета для Windows на светлый # WindowsColorScheme -Light -# Set the default app mode color scheme to the dark -# Установить цвет режима приложений по умолчанию на темный -AppMode -Dark - -# Set the default app mode color scheme to the light -# Установить цвет режима приложений по умолчанию на светлый -# AppMode -Light - # Do not show the "New App Installed" indicator # Не показывать уведомление "Установлено новое приложение" NewAppInstalledNotification -Hide diff --git a/Sophia/LTSC/Sophia.psd1 b/Sophia/LTSC/Sophia.psd1 index aec5acc150155a74263b4afc445db29fdbcbaa12..29c3e471d1826e78efac64b1cea6db1c1a2c650d 100644 GIT binary patch delta 14 VcmaFC`-XSI6lOgJ!;O^R1hxPG diff --git a/Sophia/LTSC/Sophia.psm1 b/Sophia/LTSC/Sophia.psm1 index 50744acf..85a5aa49 100644 --- a/Sophia/LTSC/Sophia.psm1 +++ b/Sophia/LTSC/Sophia.psm1 @@ -2,9 +2,11 @@ .SYNOPSIS "Windows 10 Sophia Script" (LTSC version) is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks - Version: v5.2 - Date: 08.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.2.1 + Date: 14.04.2021 + + Copyright (c) 2014–2021 farag + Copyright (c) 2019–2021 farag & oZ-Zo Thanks to all https://forum.ru-board.com members involved @@ -172,13 +174,13 @@ function CreateRestorePoint #region Privacy & Telemetry <# .SYNOPSIS - Configure the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and block connection + Configure the DiagTrack service, and connection for the Unified Telemetry Client Outbound Traffic .PARAMETER Disable - Disable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and block connection + Disable the DiagTrack service, and block connection for the Unified Telemetry Client Outbound Traffic .PARAMETER Enable - Enable the DiagTrack service, firewall rule for Unified Telemetry Client Outbound Traffic and allow connection + Enable the DiagTrack service, and allow connection for the Unified Telemetry Client Outbound Traffic .EXAMPLE DiagTrackService -Disable @@ -215,7 +217,7 @@ function DiagTrackService Get-Service -Name DiagTrack | Set-Service -StartupType Automatic Get-Service -Name DiagTrack | Start-Service - # Enable firewall rule for Unified Telemetry Client Outbound Traffic and allow connection + # Allow connection for the Unified Telemetry Client Outbound Traffic Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow } "Disable" @@ -223,7 +225,7 @@ function DiagTrackService Get-Service -Name DiagTrack | Stop-Service -Force Get-Service -Name DiagTrack | Set-Service -StartupType Disabled - # Disable firewall rule for Unified Telemetry Client Outbound Traffic and block connection + # Block connection for the Unified Telemetry Client Outbound Traffic Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block } } @@ -1151,7 +1153,7 @@ function MergeConflicts Open File Explorer to "This PC" .PARAMETER QuickAccess - Open File Explorer to "Quick access" + Open File Explorer to Quick access .EXAMPLE OpenFileExplorerTo -ThisPC @@ -1408,13 +1410,13 @@ function SnapAssist <# .SYNOPSIS - Configure the file transfer dialog box + Configure the file transfer dialog box mode .PARAMETER Detailed - Always open the file transfer dialog box in the detailed mode + Show the file transfer dialog box in the detailed mode .PARAMETER Compact - Always open the file transfer dialog box in the compact mode + Show the file transfer dialog box in the compact mode .EXAMPLE FileTransferDialog -Detailed @@ -1526,13 +1528,13 @@ function FileExplorerRibbon <# .SYNOPSIS - Configure the recycle bin files delete confirmation + Configure the recycle bin files delete confirmation dialog .PARAMETER Disable - Display/do not display the recycle bin files delete confirmation + Display/do not display the recycle bin files delete confirmation dialog .PARAMETER Enable - Display/do not display the recycle bin files delete confirmation + Display/do not display the recycle bin files delete confirmation dialog .EXAMPLE RecycleBinDeleteConfirmation -Disable @@ -1608,13 +1610,13 @@ public static void PostMessage() <# .SYNOPSIS - Configure the "3D Objects" folder in "This PC" and "Quick access" + Configure the "3D Objects" folder in "This PC" and Quick access .PARAMETER Show - Show the "3D Objects" folder in "This PC" and "Quick access" + Show the "3D Objects" folder in "This PC" and Quick access .PARAMETER Hide - Hide the "3D Objects" folder in "This PC" and "Quick access" + Hide the "3D Objects" folder in "This PC" and Quick access .EXAMPLE 3DObjects -Show @@ -1681,13 +1683,13 @@ function 3DObjects <# .SYNOPSIS - Configure frequently used folders in "Quick access" + Configure frequently used folders in Quick access .PARAMETER Show - Show frequently used folders in "Quick access" + Show frequently used folders in Quick access .PARAMETER Hide - Hide frequently used folders in "Quick access" + Hide frequently used folders in Quick access .EXAMPLE QuickAccessFrequentFolders -Show @@ -2021,57 +2023,6 @@ function WindowsColorScheme $Dark ) - switch ($PSCmdlet.ParameterSetName) - { - "Light" - { - New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -PropertyType DWord -Value 1 -Force - } - "Dark" - { - New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -PropertyType DWord -Value 0 -Force - } - } -} - -<# - .SYNOPSIS - Configure the default app mode color scheme - - .PARAMETER Light - Set the default app mode color scheme to the light - - .PARAMETER Dark - Set the default app mode color scheme to the dark - - .EXAMPLE - AppMode -Light - - .EXAMPLE - AppMode -Dark - - .NOTES - Current user -#> -function AppMode -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Light" - )] - [switch] - $Light, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Dark" - )] - [switch] - $Dark - ) - switch ($PSCmdlet.ParameterSetName) { "Light"