From f6c931809968b0657542868c737a8cff7fba8952 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 14 Apr 2021 20:21:05 +0300 Subject: [PATCH] 14.04.2021 v5.10.1 --- Sophia/PowerShell 5.1/Functions.ps1 | 74 ++++++++++++++---- Sophia/PowerShell 5.1/Sophia.ps1 | 108 +++++++++++++++++-------- Sophia/PowerShell 5.1/Sophia.psd1 | Bin 1770 -> 1774 bytes Sophia/PowerShell 5.1/Sophia.psm1 | 117 +++++++++++++++------------- 4 files changed, 195 insertions(+), 104 deletions(-) diff --git a/Sophia/PowerShell 5.1/Functions.ps1 b/Sophia/PowerShell 5.1/Functions.ps1 index 83d6058f..28a1eaf5 100644 --- a/Sophia/PowerShell 5.1/Functions.ps1 +++ b/Sophia/PowerShell 5.1/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.10.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 @@ -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/PowerShell 5.1/Sophia.ps1 b/Sophia/PowerShell 5.1/Sophia.ps1 index 9665a40b..c73eabc4 100644 --- a/Sophia/PowerShell 5.1/Sophia.ps1 +++ b/Sophia/PowerShell 5.1/Sophia.ps1 @@ -2,29 +2,34 @@ .SYNOPSIS Default preset file for "Windows 10 Sophia Script" - Version: v5.10 - Date: 09.04.2021 - Copyright (c) 2015–2021 farag & oZ-Zo + Version: v5.10.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 versions - Versions: 2004 (20H1)/20H2 (2009)/21H1 + Versions: 2004/20H2/21H1 Builds: 19041/19042/19043 Editions: Home/Pro/Enterprise Architecture: x64 @@ -54,15 +59,50 @@ #Requires -RunAsAdministrator #Requires -Version 5.1 +[CmdletBinding()] +param +( + [Parameter(Mandatory = $false)] + [string[]] + $Functions +) + 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, 2014–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 @@ -88,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 @@ -105,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) @@ -262,7 +302,7 @@ MergeConflicts -Show # Открывать проводник для: "Этот компьютер" OpenFileExplorerTo -ThisPC -# Open File Explorer to: "Quick access" (default value) +# Open File Explorer to: Quick access (default value) # Открывать проводник для: "Быстрый доступ" (значение по умолчанию) # OpenFileExplorerTo -QuickAccess @@ -311,15 +351,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 @@ -330,28 +370,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 @@ -374,11 +414,11 @@ TaskbarSearch -Hide # Показать поле поиска на панели задач (значение по умолчанию) # TaskbarSearch -SearchBox -# Do not show the "Windows Ink Workspace" button on the taskbar +# Do not show the Windows Ink Workspace button on the taskbar # Не показывать кнопку Windows Ink Workspace на панели задач WindowsInkWorkspace -Hide -# Show the "Windows Ink Workspace" button in taskbar (default value) +# Show Windows Ink Workspace button on the taskbar (default value) # Показать кнопку Windows Ink Workspace на панели задач (значение по умолчанию) # WindowsInkWorkspace -Show @@ -411,7 +451,7 @@ ControlPanelView -LargeIcons # ControlPanelView -SmallIcons # View the Control Panel icons by: category (default value) -# Просмотр значки Панели управления как "категория" (значение по умолчанию) +# Просмотр значки Панели управления как: категория (значение по умолчанию) # ControlPanelView -Category # Set the Windows mode color scheme to the dark @@ -422,12 +462,12 @@ WindowsColorScheme -Dark # Установить режим цвета для Windows на светлый # WindowsColorScheme -Light -# Set the default app mode color scheme to the dark -# Установить цвет режима приложений по умолчанию на темный +# Set the app mode color scheme to the dark +# Установить цвет режима приложений на темный AppMode -Dark -# Set the default app mode color scheme to the light -# Установить цвет режима приложений по умолчанию на светлый +# Set the app mode color scheme to the light +# Установить цвет режима приложений на светлый # AppMode -Light # Do not show the "New App Installed" indicator diff --git a/Sophia/PowerShell 5.1/Sophia.psd1 b/Sophia/PowerShell 5.1/Sophia.psd1 index 836797f749dcdf841010ca7da75e2e5b46e3816d..05c33839906af42f796ee69d8b0d760b93192442 100644 GIT binary patch delta 14 VcmaFG`;K?QG-f>p!;Moz*#Ik|1snhX delta 10 RcmaFI`-*qMw2iYu*Z>^_1ik @@ -8418,7 +8423,7 @@ function UninstallUWPApps RestoreUWPAppsUWPApps .NOTES - UWP apps can be restored only if they were uninstalled only for the current user + UWP apps can be restored only if they were uninstalled for the current user .NOTES A pop-up dialog box enables the user to select packages @@ -8513,7 +8518,7 @@ function RestoreUWPApps #region Functions function Get-AppxManifest { - Write-Verbose -Message "Patient" -Verbose + Write-Verbose -Message $Localization.Patient -Verbose # Тут нельзя напрямую вписать -PackageTypeFilter Bundle, так как иначе не выдается нужное свойство InstallLocation. Только сравнивать с $Bundles $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name