From 53304d3aef062a6ad2e6ba22cdd71a64448dd4b5 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 28 Jan 2023 16:14:39 +0300 Subject: [PATCH] Improved Scheduled tasks creation. fixed #440 --- .../Module/Sophia.psm1 | 201 +++++++----- src/Sophia_Script_for_Windows_10/Sophia.ps1 | 34 +- .../Module/Sophia.psm1 | 194 +++++++----- .../Sophia.ps1 | 34 +- .../Module/Sophia.psm1 | 198 +++++++----- .../Sophia.ps1 | 34 +- .../Module/Sophia.psm1 | 199 +++++++----- .../Sophia.ps1 | 34 +- .../Localizations/en-US/Sophia.psd1 | 1 + .../Module/Sophia.psm1 | 290 ++++++++++++------ src/Sophia_Script_for_Windows_11/Sophia.ps1 | 34 +- .../Module/Sophia.psm1 | 200 +++++++----- .../Sophia.ps1 | 34 +- 13 files changed, 877 insertions(+), 610 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 3e5011e8..bdba28dc 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -776,12 +776,21 @@ function DiagnosticDataLevel New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1 } + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force } "Default" { # Optional diagnostic data + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force @@ -6200,59 +6209,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -6374,28 +6330,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -6405,33 +6356,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -6439,11 +6407,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -7498,6 +7472,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -7650,6 +7677,10 @@ function RecommendedTroubleshooting } # Set the OS level of diagnostic data gathering to "Optional diagnostic data" + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force @@ -10211,7 +10242,7 @@ function UninstallUWPApps Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Patient -Verbose - $AppxPackages = Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages} + $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages}) $PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName foreach ($AppxPackage in $AppxPackages) @@ -11225,7 +11256,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index 6db7da81..72c22a3f 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1 @@ -725,14 +725,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -800,6 +792,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + <# Save screenshots by pressing Win+PrtScr on the Desktop The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled @@ -1128,12 +1128,12 @@ GPUScheduling -Enable #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -1141,12 +1141,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -1154,12 +1154,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий 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 09e922df..2b7fc7dc 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 @@ -716,6 +716,10 @@ function DiagnosticDataLevel { New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Force } + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force @@ -723,6 +727,10 @@ function DiagnosticDataLevel "Default" { # Full level + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force @@ -4903,59 +4911,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -5077,28 +5032,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -5108,33 +5058,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -5142,11 +5109,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -6201,6 +6174,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -7938,7 +7964,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" 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 87059e10..680829d5 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 @@ -587,14 +587,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -662,6 +654,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + # Save screenshots by pressing Win+PrtScr on the Desktop # Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе WinPrtScrFolder -Desktop @@ -812,12 +812,12 @@ SetAppGraphicsPerformance #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -825,12 +825,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -838,12 +838,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий 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 0bfcf06e..7a4acecf 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 @@ -716,6 +716,10 @@ function DiagnosticDataLevel { New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Force } + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force @@ -723,6 +727,10 @@ function DiagnosticDataLevel "Default" { # Optional diagnostic data + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force @@ -5290,59 +5298,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -5464,28 +5419,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -5495,33 +5445,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -5529,11 +5496,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -6588,6 +6561,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -6702,6 +6728,10 @@ function RecommendedTroubleshooting } # Set the OS level of diagnostic data gathering to "Optional diagnostic data" + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force @@ -9039,7 +9069,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" 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 5628d39b..18f24da8 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 @@ -642,14 +642,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -717,6 +709,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + # Save screenshots by pressing Win+PrtScr on the Desktop # Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе WinPrtScrFolder -Desktop @@ -951,12 +951,12 @@ GPUScheduling -Enable #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -964,12 +964,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -977,12 +977,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий 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 65027382..02d5f013 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 @@ -778,12 +778,21 @@ function DiagnosticDataLevel New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1 } + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force } "Default" { # Optional diagnostic data + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force @@ -6208,59 +6217,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -6382,28 +6338,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -6413,33 +6364,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -6447,11 +6415,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -7506,6 +7480,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -7658,6 +7685,10 @@ function RecommendedTroubleshooting } # Set the OS level of diagnostic data gathering to "Optional diagnostic data" + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force @@ -11253,7 +11284,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" 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 1998eaed..6d27c220 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 @@ -734,14 +734,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -809,6 +801,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + <# Save screenshots by pressing Win+PrtScr on the Desktop The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled @@ -1137,12 +1137,12 @@ GPUScheduling -Enable #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -1150,12 +1150,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -1163,12 +1163,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий diff --git a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 index ef3e8cb4..35e1567b 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 @@ -38,6 +38,7 @@ UWPAppsTitle = UWP Apps HEVCDownloading = Downloading HEVC Video Extensions from Device Manufacturer... ~2,8 MB GraphicsPerformanceTitle = Graphics performance preference GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +ScheduledTaskPresented = You're trying to create the task while it was already created as "{0}". Remove the task and try again CleanupTaskNotificationTitle = Windows clean up CleanupTaskNotificationEvent = Run task to clean up Windows unused files and updates? CleanupTaskDescription = Cleaning up Windows unused files and updates using built-in Disk cleanup app diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 1bc1c33f..f95db7a7 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -769,6 +769,11 @@ function DiagnosticDataLevel New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1 } + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force } @@ -777,6 +782,11 @@ function DiagnosticDataLevel # Optional diagnostic data Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force } @@ -5738,59 +5748,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -5912,28 +5869,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -5943,33 +5895,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -5977,11 +5946,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -7036,6 +7011,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -7188,6 +7216,10 @@ function RecommendedTroubleshooting } # Set the OS level of diagnostic data gathering to "Optional diagnostic data" + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force @@ -10691,7 +10723,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" @@ -10806,6 +10838,13 @@ function CleanupTask [switch] $Register, + [Parameter( + Mandatory = $false + )] + [ValidateSet("30", "60", "90")] + [string] + $Period, + [Parameter( Mandatory = $true, ParameterSetName = "Delete" @@ -10828,6 +10867,27 @@ function CleanupTask return } + # Checking if we're trying to create the task when it was already created as another user + if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName CleanupTask) + { + # Also we can parse $env:SystemRoot\System32\Tasks\Sophia\CleanupTask to check if the task was created + $ScheduleService = New-Object -ComObject Schedule.Service + $ScheduleService.Connect() + $ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "CleanupTask"} | Foreach-Object { + # Get user's SID the task was created as + $SID = ([xml]$_.xml).Task.Principals.Principal.UserID + } + # Convert SID to username + $TaskUserAccount = (New-Object System.Security.Principal.SecurityIdentifier($SID)).Translate([System.Security.Principal.NTAccount]).Value -split "\\" | Select-Object -Last 1 + + if ($TaskUserAccount -ne $env:USERNAME) + { + Write-Verbose -Message ($Localization.ScheduledTaskPresented -f $TaskUserAccount) -Verbose + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue + return + } + } + # Remove all old tasks # We have to use -ErrorAction Ignore in both cases, unless we get an error Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process { @@ -11007,7 +11067,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $ToastNotification" $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest - $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 30 -At 9pm + $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval $Period -At 9pm $Parameters = @{ TaskName = "Windows Cleanup Notification" TaskPath = "Sophia" @@ -11092,6 +11152,13 @@ function SoftwareDistributionTask [switch] $Register, + [Parameter( + Mandatory = $false + )] + [ValidateSet("30", "60", "90")] + [string] + $Period, + [Parameter( Mandatory = $true, ParameterSetName = "Delete" @@ -11104,6 +11171,27 @@ function SoftwareDistributionTask { "Register" { + # Checking if we're trying to create the task when it was already created as another user + if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution) + { + # Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created + $ScheduleService = New-Object -ComObject Schedule.Service + $ScheduleService.Connect() + $ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object { + # Get user's SID the task was created as + $SID = ([xml]$_.xml).Task.Principals.Principal.UserID + } + # Convert SID to username + $TaskUserAccount = (New-Object System.Security.Principal.SecurityIdentifier($SID)).Translate([System.Security.Principal.NTAccount]).Value -split "\\" | Select-Object -Last 1 + + if ($TaskUserAccount -ne $env:USERNAME) + { + Write-Verbose -Message ($Localization.ScheduledTaskPresented -f $TaskUserAccount) -Verbose + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue + return + } + } + # Remove all old tasks # We have to use -ErrorAction Ignore in both cases, unless we get an error Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process { @@ -11167,7 +11255,7 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SoftwareDistributionTask" $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest - $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 90 -At 9pm + $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval $Period -At 9pm $Parameters = @{ TaskName = "SoftwareDistribution" TaskPath = "Sophia" @@ -11247,6 +11335,13 @@ function TempTask [switch] $Register, + [Parameter( + Mandatory = $false + )] + [ValidateSet("30", "60", "90")] + [string] + $Period, + [Parameter( Mandatory = $true, ParameterSetName = "Delete" @@ -11259,6 +11354,27 @@ function TempTask { "Register" { + # Checking if we're trying to create the task when it was already created as another user + if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp) + { + # Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created + $ScheduleService = New-Object -ComObject Schedule.Service + $ScheduleService.Connect() + $ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object { + # Get user's SID the task was created as + $SID = ([xml]$_.xml).Task.Principals.Principal.UserID + } + # Convert SID to username + $TaskUserAccount = (New-Object System.Security.Principal.SecurityIdentifier($SID)).Translate([System.Security.Principal.NTAccount]).Value -split "\\" | Select-Object -Last 1 + + if ($TaskUserAccount -ne $env:USERNAME) + { + Write-Verbose -Message ($Localization.ScheduledTaskPresented -f $TaskUserAccount) -Verbose + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue + return + } + } + # Remove all old tasks # We have to use -ErrorAction Ignore in both cases, unless we get an error Get-ScheduledTask -TaskPath "\Sophia Script\", "\SophiApp\" -ErrorAction Ignore | ForEach-Object -Process { @@ -11321,7 +11437,7 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempTask" $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest - $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 60 -At 9pm + $Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval $Period -At 9pm $Parameters = @{ TaskName = "Temp" TaskPath = "Sophia" diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index da5ce8a5..edf5cdbd 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1 @@ -672,14 +672,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -747,6 +739,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + <# Save screenshots by pressing Win+PrtScr on the Desktop The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled @@ -1068,12 +1068,12 @@ GPUScheduling -Enable #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -1081,12 +1081,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -1094,12 +1094,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий 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 06b3e572..c10a8bbd 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 @@ -771,6 +771,11 @@ function DiagnosticDataLevel New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1 } + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force } @@ -779,6 +784,11 @@ function DiagnosticDataLevel # Optional diagnostic data Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Force -ErrorAction Ignore Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type CLEAR + + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force } @@ -5746,59 +5756,6 @@ function PowerPlan } } -<# - .SYNOPSIS - The the latest installed .NET runtime for all apps usage - - .PARAMETER Enable - Use the latest installed .NET runtime for all apps - - .PARAMETER Disable - Do not use the latest installed .NET runtime for all apps - - .EXAMPLE - LatestInstalled.NET -Enable - - .EXAMPLE - LatestInstalled.NET -Disable - - .NOTES - Machine-wide -#> -function LatestInstalled.NET -{ - 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force - } - "Disable" - { - Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore - } - } -} - <# .SYNOPSIS Network adapters power management @@ -5920,28 +5877,23 @@ function IPv6Component ParameterSetName = "Enable" )] [switch] - $Enable + $Enable, + + [Parameter( + Mandatory = $true, + ParameterSetName = "PreferIPv4overIPv6" + )] + [switch] + $PreferIPv4overIPv6 ) - try + function IPv6SupportByISP { - # Check the internet connection - $Parameters = @{ - Uri = "https://www.google.com" - Method = "Head" - DisableKeepAlive = $true - UseBasicParsing = $true - } - if (-not (Invoke-WebRequest @Parameters).StatusDescription) - { - return - } - try { - # Check whether the https://ipv6-test.com site is alive + # Check the internet connection $Parameters = @{ - Uri = "https://ipv6-test.com" + Uri = "https://www.google.com" Method = "Head" DisableKeepAlive = $true UseBasicParsing = $true @@ -5951,33 +5903,50 @@ function IPv6Component return } - # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com - $Parameters = @{ - Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" - UseBasicParsing = $true + try + { + # Check whether the https://ipv6-test.com site is alive + $Parameters = @{ + Uri = "https://ipv6-test.com" + Method = "Head" + DisableKeepAlive = $true + UseBasicParsing = $true + } + if (-not (Invoke-WebRequest @Parameters).StatusDescription) + { + return + } + + # Check whether the ISP supports IPv6 protocol using https://ipv6-test.com + $Parameters = @{ + Uri = "https://v4v6.ipv6-test.com/api/myip.php?json" + UseBasicParsing = $true + } + $IPVersion = (Invoke-RestMethod @Parameters).proto + } + catch [System.Net.WebException] + { + Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") + Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + + Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } - $IPVersion = (Invoke-RestMethod @Parameters).proto } catch [System.Net.WebException] { - Write-Warning -Message ($Localization.NoResponse -f "https://ipv6-test.com") - Write-Error -Message ($Localization.NoResponse -f "https://ipv6-test.com") -ErrorAction SilentlyContinue + Write-Warning -Message $Localization.NoInternetConnection + Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue } } - catch [System.Net.WebException] - { - Write-Warning -Message $Localization.NoInternetConnection - Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue - - Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue - } switch ($PSCmdlet.ParameterSetName) { "Disable" { + IPv6SupportByISP + if ($IPVersion -ne "ipv6") { Disable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 @@ -5985,11 +5954,17 @@ function IPv6Component } "Enable" { + IPv6SupportByISP + if ($IPVersion -eq "ipv6") { Enable-NetAdapterBinding -Name * -ComponentID ms_tcpip6 } } + "PreferIPv4overIPv6" + { + New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -PropertyType DWord -Value 32 -Force + } } } @@ -7044,6 +7019,59 @@ public static string GetString(uint strId) } } +<# + .SYNOPSIS + The the latest installed .NET runtime for all apps usage + + .PARAMETER Enable + Use the latest installed .NET runtime for all apps + + .PARAMETER Disable + Do not use the latest installed .NET runtime for all apps + + .EXAMPLE + LatestInstalled.NET -Enable + + .EXAMPLE + LatestInstalled.NET -Disable + + .NOTES + Machine-wide +#> +function LatestInstalled.NET +{ + 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\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force + } + "Disable" + { + Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore + } + } +} + <# .SYNOPSIS The location to save screenshots by pressing Win+PrtScr @@ -7196,6 +7224,10 @@ function RecommendedTroubleshooting } # Set the OS level of diagnostic data gathering to "Optional diagnostic data" + if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack)) + { + New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force + } New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force @@ -10719,7 +10751,7 @@ function SetAppGraphicsPerformance New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force } New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force - Write-Verbose -Message ("{0}" -f $OpenFileDialog.FileName) -Verbose + Write-Verbose -Message $OpenFileDialog.FileName -Verbose } } "1" 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 81261195..f5e99a2e 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 @@ -681,14 +681,6 @@ PowerPlan -High # Установить схему управления питанием на "Сбалансированная" (значение по умолчанию) # PowerPlan -Balanced -# Use the latest installed .NET runtime for all apps -# Использовать последнюю установленную среду выполнения .NET для всех приложений -LatestInstalled.NET -Enable - -# Do not use the latest installed .NET runtime for all apps (default value) -# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) -# LatestInstalled.NET -Disable - # Do not allow the computer to turn off the network adapters to save power # Запретить отключение всех сетевых адаптеров для экономии энергии NetworkAdaptersSavePower -Disable @@ -756,6 +748,14 @@ SetUserShellFolderLocation -Root #> # SetUserShellFolderLocation -Default +# Use the latest installed .NET runtime for all apps +# Использовать последнюю установленную среду выполнения .NET для всех приложений +LatestInstalled.NET -Enable + +# Do not use the latest installed .NET runtime for all apps (default value) +# Не использовать последнюю установленную версию .NET для всех приложений (значение по умолчанию) +# LatestInstalled.NET -Disable + <# Save screenshots by pressing Win+PrtScr on the Desktop The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled @@ -1077,12 +1077,12 @@ GPUScheduling -Enable #region Scheduled tasks <# Create the "Windows Cleanup" scheduled task for cleaning up Windows unused files and updates - A native interactive toast notification pops up every 30 days. The task runs every 30 days + A native interactive toast notification pops up every 30 days. The "Period" parameter specifies how often the task is run, in days Создать задачу "Windows Cleanup" по очистке неиспользуемых файлов и обновлений Windows в Планировщике заданий - Нативный интерактивный тост всплывает каждые 30 дней. Задача выполняется каждые 30 дней + Нативный интерактивный тост всплывает каждые 30 дней. Параметр "Period" указывает на частоту запуска задания в днях #> -CleanupTask -Register +CleanupTask -Register -Period 30 # Delete the "Windows Cleanup" and "Windows Cleanup Notification" scheduled tasks for cleaning up Windows unused files and updates # Удалить задачи "Windows Cleanup" и "Windows Cleanup Notification" по очистке неиспользуемых файлов и обновлений Windows из Планировщика заданий @@ -1090,12 +1090,12 @@ CleanupTask -Register <# Create the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder - The task will wait until the Windows Updates service finishes running. The task runs every 90 days + The task will wait until the Windows Updates service finishes running. The "Period" parameter specifies how often the task is run, in days. The task runs every 90 days by default Создать задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download в Планировщике заданий - Задача будет ждать, пока служба обновлений Windows не закончит работу. Задача выполняется каждые 90 дней + Задача будет ждать, пока служба обновлений Windows не закончит работу. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 90 дней. #> -SoftwareDistributionTask -Register +SoftwareDistributionTask -Register -Period 90 # Delete the "SoftwareDistribution" scheduled task for cleaning up the %SystemRoot%\SoftwareDistribution\Download folder # Удалить задачу "SoftwareDistribution" по очистке папки %SystemRoot%\SoftwareDistribution\Download из Планировщика заданий @@ -1103,12 +1103,12 @@ SoftwareDistributionTask -Register <# Create the "Temp" scheduled task for cleaning up the %TEMP% folder - Only files older than one day will be deleted. The task runs every 60 days + Only files older than one day will be deleted. The "Period" parameter specifies how often the task is run, in days. The task runs every 60 days by default Создать задачу "Temp" в Планировщике заданий по очистке папки %TEMP% - Удаляться будут только файлы старше одного дня. Задача выполняется каждые 60 дней + Удаляться будут только файлы старше одного дня. Параметр "Period" указывает на частоту запуска задания в днях. По умолчанию задача выполняется каждые 60 дней. #> -TempTask -Register +TempTask -Register -Period 60 # Delete the "Temp" scheduled task for cleaning up the %TEMP% folder # Удалить задачу "Temp" по очистке папки %TEMP% из Планировщика заданий