From 4411304288e252bf69b9b65f125593df75da2196 Mon Sep 17 00:00:00 2001 From: farag2 Date: Tue, 12 May 2020 22:46:21 +0300 Subject: [PATCH] v4.2 12.05.2020 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Updated - Moved from the "Read-Host" cmdlet to $Host.UI.PromptForChoice(). - Updated "Create a task in the Task Scheduler to start Windows cleaning up"; - A [toast notification](https://docs.microsoft.com/ru-ru/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts) will be activated before starting cleaning up; - Now cleanmgr.exe window starts minimized; - Now using DISM to clean up unused Windows updates instead of cleanmgr.exe ```cmd DISM.exe /Online /English /Cleanup-Image /StartComponentCleanup /NoRestart ``` - Minor changes; - Thanks [westlife](http://forum.ru-board.com/profile.cgi?action=show&member=westlife) for the tips; - Also you can test [20H1 version](https://gist.github.com/farag2/5a6d9952247aefe42ba81a9d95507765). ## Обновлено - Вместо командлета "Read-Host" используется $Host.UI.PromptForChoice(); - Обновлен раздел "Создать задачу в Планировщике задач по очистке обновлений Windows"; - Перед запуском очистки активируется [всплывающее уведомление](https://docs.microsoft.com/ru-ru/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts); - Теперь окно cleanmgr.exe запускается вернутым; - Очистка ненужных обновлений теперь происходит с помощью DISM ```cmd DISM.exe /Online /English /Cleanup-Image /StartComponentCleanup /NoRestart ``` - Незначительные изменения; - Спасибо [westlife](http://forum.ru-board.com/profile.cgi?action=show&member=westlife) за подсказки; - Также можете протестировать [версию 20H1](https://gist.github.com/farag2/5a6d9952247aefe42ba81a9d95507765). --- Win 10.ps1 | 1206 ++++++++++++++++++++++++---------------------------- 1 file changed, 549 insertions(+), 657 deletions(-) diff --git a/Win 10.ps1 b/Win 10.ps1 index 046bb834..a6d22a0c 100644 --- a/Win 10.ps1 +++ b/Win 10.ps1 @@ -3,7 +3,9 @@ "Windows 10 Setup Script" is a set of tweaks for OS fine-tuning and automating the routine tasks. .DESCRIPTION Supported Windows versions: - Windows 10 1903/1909 (19H1/19H2), 18362/18363 build, x64 only. Tested on Pro/Enterprise editions. + Windows 10 1903/1909 (19H1/19H2), 18362/18363 build, x64 only + + Tested on Home/Pro/Enterprise editions Check whether file is encoded in UTF-8 with BOM. PowerShell must be run with elevated privileges; @@ -18,8 +20,8 @@ .EXAMPLE PS C:\> & '.\Win 10.ps1' .NOTES - Version: v4.1 - Date: 03.05.2020 + Version: v4.2 + Date: 12.05.2020 Written by: farag Thanks to all http://forum.ru-board.com members involved Ask a question on @@ -79,6 +81,21 @@ if (-not ([IntPtr]::Size -eq 8)) } break } + +# Detect whether the script is running via PowerShell ISE +# Определить, запущен ли скрипт в PowerShell ISE +if ($psISE) +{ + if ($RU) + { + Write-Warning -Message "Скрипт не может быть запущен в PowerShell ISE" + } + else + { + Write-Warning -Message "The script can not be run via PowerShell ISE" + } + break +} #endregion Check #region Begin @@ -100,128 +117,86 @@ if ($RU) # Создать точку восстановления if ($RU) { - Write-Host "`nЧтобы создать точку восстановления, введите букву: " -NoNewline - Write-Host "[Y]es" -ForegroundColor Yellow -NoNewline - Write-Host " или " -NoNewline - Write-Host "[N]o" -ForegroundColor Yellow -NoNewline - Write-Host ", чтобы пропустить" -NoNewline - Write-Host "`nТакже, чтобы пропустить, нажмите Enter" -NoNewline + $Title = "Точка восстановления" + $Message = "Чтобы создайте точку восстановления, введите необходимую букву" + $Options = "&Создать", "&Не создавать", "&Пропустить" } else { - Write-Host "`nTo сreate a restore point type: " -NoNewline - Write-Host "[Y]es" -ForegroundColor Yellow -NoNewline - Write-Host " or " -NoNewline - Write-Host "[N]o" -ForegroundColor Yellow -NoNewline - Write-Host " to skip" -NoNewline - Write-Host "`nAlso press Enter to skip" -NoNewline + $Title = "Restore point" + $Message = "To create a restore point enter the required letter" + $Options = "&Create", "&Do not create", "&Skip" } -do +$DefaultChoice = 2 +$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + +switch ($Result) { - $Prompt = Read-Host -Prompt " " - if ([string]::IsNullOrEmpty($Prompt)) + "0" { - break + if (-not (Get-ComputerRestorePoint)) + { + Enable-ComputerRestore -Drive $env:SystemDrive + } + # Set system restore point creation frequency to 5 minutes + # Установить частоту создания точек восстановления на 5 минут + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name SystemRestorePointCreationFrequency -PropertyType DWord -Value 5 -Force + # Descriptive name format for the restore point: ..