diff --git a/Win 10.ps1 b/Win 10.ps1 index 99ac790a..5a376f4c 100644 --- a/Win 10.ps1 +++ b/Win 10.ps1 @@ -4,7 +4,7 @@ .DESCRIPTION Supported Windows versions: 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 @@ -21,17 +21,19 @@ .EXAMPLE PS C:\> & '.\Win 10.ps1' .NOTES - Version: v4.3 - Date: 21.05.2020 - Written by: farag + Version: v4.4 + Date: 02.06.2020 + Written by: farag & oZ-Zo Thanks to all http://forum.ru-board.com members involved + Ask a question on - - http://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 - - https://habr.com/en/post/465365/ - - https://4pda.ru/forum/index.php?s=&showtopic=523489&view=findpost&p=95909388 - - https://forums.mydigitallife.net/threads/powershell-script-setup-windows-10.80139/ - - https://www.reddit.com/r/Windows10/comments/ctg8jw/powershell_script_setup_windows_10/ - Copyright (c) 2020 farag + http://forum.ru-board.com/topic.cgi?forum=62&topic=30617#15 + https://habr.com/en/post/465365/ + https://4pda.ru/forum/index.php?showtopic=523489&st=42860#entry95909388 + https://forums.mydigitallife.net/threads/powershell-script-setup-windows-10.81675/ + https://www.reddit.com/r/PowerShell/comments/go2n5v/powershell_script_setup_windows_10/ + + Copyright (c) 2020 farag & oZ-Zo .LINK https://github.com/farag2/Windows-10-Setup-Script #> @@ -55,32 +57,40 @@ else # Detect the OS bitness # Определить разрядность ОС -if (-not ([Environment]::Is64BitOperatingSystem)) +switch ([Environment]::Is64BitOperatingSystem) { - if ($RU) + $false { - Write-Warning -Message "Скрипт поддерживает только Windows 10 x64" - } - else - { - Write-Warning -Message "The script supports Windows 10 x64 only" + if ($RU) + { + Write-Warning -Message "Скрипт поддерживает только Windows 10 x64" + } + else + { + Write-Warning -Message "The script supports Windows 10 x64 only" + } + break } - break + Default {} } # Detect the PowerShell bitness # Определить разрядность PowerShell -if (-not ([IntPtr]::Size -eq 8)) +switch ([IntPtr]::Size -eq 8) { - if ($RU) + $false { - Write-Warning -Message "Скрипт поддерживает только PowerShell x64" - } - else - { - Write-Warning -Message "The script supports PowerShell x64 only" + if ($RU) + { + Write-Warning -Message "Скрипт поддерживает только PowerShell x64" + } + else + { + Write-Warning -Message "The script supports PowerShell x64 only" + } + break } - break + Default {} } # Detect whether the script is running via PowerShell ISE @@ -229,7 +239,7 @@ New-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\UserDataSvc -Name # Stop event trace sessions # Остановить сеансы отслеживания событий -Get-EtwTraceSession -Name DiagLog -ErrorAction Ignore | Remove-EtwTraceSession +Get-EtwTraceSession -Name DiagLog -ErrorAction Ignore | Remove-EtwTraceSession -ErrorAction Ignore # Turn off the data collectors at the next computer restart # Отключить сборщики данных при следующем запуске ПК @@ -428,7 +438,6 @@ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ # Increase taskbar transparency # Увеличить прозрачность панели задач New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name UseOLEDTaskbarTransparency -PropertyType DWord -Value 1 -Force -New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\Dwm -Name ForceEffectMode -PropertyType DWord -Value 1 -Force # Do not show when snapping a window, what can be attached next to it # Не показывать при прикреплении окна, что можно прикрепить рядом с ним @@ -693,12 +702,14 @@ if ($UninstallString) { Write-Verbose -Message "Uninstalling OneDrive" -Verbose } - Stop-Process -Name OneDrive -Force - Stop-Process -Name FileCoAuth -ErrorAction Ignore -Force + Stop-Process -Name OneDrive -Force -ErrorAction Ignore + Stop-Process -Name FileCoAuth -Force -ErrorAction Ignore + # Save all opened folders in order to restore them after File Explorer restarting # Сохранить все открытые папки, чтобы восстановить их после перезапуска проводника Clear-Variable -Name OpenedFolders -Force -ErrorAction Ignore $OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() + # Getting link to the OneDriveSetup.exe and its' argument(s) # Получаем ссылку на OneDriveSetup.exe и его аргумент(ы) [string[]]$OneDriveSetup = ($UninstallString -Replace("\s*/",",/")).Split(",").Trim() @@ -711,6 +722,7 @@ if ($UninstallString) Start-Process -FilePath $OneDriveSetup[0] -ArgumentList $OneDriveSetup[1..2] -Wait } Stop-Process -Name explorer -Force + # Restoring closed folders # Восстановляем закрытые папки foreach ($OpenedFolder in $OpenedFolders) @@ -720,6 +732,7 @@ if ($UninstallString) Invoke-Item -Path $OpenedFolder } } + # Getting the OneDrive user folder path # Получаем путь до папки пользователя OneDrive $OneDriveUserFolder = Get-ItemPropertyValue -Path HKCU:\Environment -Name OneDrive @@ -739,12 +752,14 @@ if ($UninstallString) } Invoke-Item -Path $OneDriveUserFolder } + Remove-ItemProperty -Path HKCU:\Environment -Name OneDrive, OneDriveConsumer -Force -ErrorAction Ignore Remove-Item -Path HKCU:\Software\Microsoft\OneDrive -Recurse -Force -ErrorAction Ignore Remove-Item -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\OneDrive -Recurse -Force -ErrorAction Ignore Remove-Item -Path "$env:ProgramData\Microsoft OneDrive" -Recurse -Force -ErrorAction Ignore Remove-Item -Path $env:SystemDrive\OneDriveTemp -Recurse -Force -ErrorAction Ignore Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false + # Getting the OneDrive folder path # Получаем путь до папки OneDrive $OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent) @@ -781,9 +796,11 @@ if ($UninstallString) } while ($Locked) } - Remove-Item -Path $OneDriveFolder -Recurse -Force + + Remove-Item -Path $OneDriveFolder -Recurse -Force -ErrorAction Ignore Remove-Item -Path $env:LOCALAPPDATA\OneDrive -Recurse -Force -ErrorAction Ignore Remove-Item -Path $env:LOCALAPPDATA\Microsoft\OneDrive -Recurse -Force -ErrorAction Ignore + Remove-Item -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Force -ErrorAction Ignore } #endregion OneDrive @@ -973,7 +990,7 @@ $ExcludedCapabilities = @( -