Browse Source

Some improvements

master
Dmitry Nefedov 11 months ago
parent
commit
bbbda744b2
  1. 16
      Wrapper/Config/config_Windows_11.json
  2. 18
      Wrapper/Localizations/de-DE/tooltip_Windows_11.json
  3. 18
      Wrapper/Localizations/en-US/tooltip_Windows_11.json
  4. 14
      Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
  5. 24
      src/Sophia_Script_for_Windows_10/Functions.ps1
  6. 740
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  7. 2
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  8. 24
      src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
  9. 417
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  10. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  11. 24
      src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
  12. 730
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  13. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  14. 24
      src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
  15. 740
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  16. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  17. 24
      src/Sophia_Script_for_Windows_11/Functions.ps1
  18. 542
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  19. 18
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  20. 24
      src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
  21. 540
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  22. 14
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

16
Wrapper/Config/config_Windows_11.json

@ -559,6 +559,22 @@
"Preset": "Zero",
"WindowsDefault": "Three"
},
{
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "SearchHighlights",
"Arg": {
"Zero": {
"Tag": "Hide"
},
"One": {
"Tag": "Show"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "UI & Personalization",
"Control": "cmb",

18
Wrapper/Localizations/de-DE/tooltip_Windows_11.json

@ -489,6 +489,20 @@
}
}
},
{
"Region": "UI & Personalization",
"Function": "SearchHighlights",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Suchhighlights ausblenden."
},
"One": {
"Tag": "Show",
"ToolTip": "Suchhighlights anzeigen (Standardeinstellung)."
}
}
},
{
"Region": "UI & Personalization",
"Function": "CopilotButton",
@ -1282,11 +1296,11 @@
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Holen Sie sich keine Windows-Updates, sobald sie für Ihr Gerät verfügbar sind (Standardeinstellung)."
"ToolTip": "Sie erhalten die neuesten Updates nicht, sobald sie verfügbar sind (Standardeinstellung)."
},
"One": {
"Tag": "Enable",
"ToolTip": "Holen Sie sich Windows-Updates, sobald sie für Ihr Gerät verfügbar sind."
"ToolTip": "Erhalten Sie die neuesten Updates, sobald sie verfügbar sind."
}
}
},

18
Wrapper/Localizations/en-US/tooltip_Windows_11.json

@ -489,6 +489,20 @@
}
}
},
{
"Region": "UI & Personalization",
"Function": "SearchHighlights",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Hide search highlights."
},
"One": {
"Tag": "Show",
"ToolTip": "Show search highlights (default value)."
}
}
},
{
"Region": "UI & Personalization",
"Function": "CopilotButton",
@ -1282,11 +1296,11 @@
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Do not get Windows updates as soon as they're available for your device (default value)."
"ToolTip": "Do not get the latest updates as soon as they're available (default value)."
},
"One": {
"Tag": "Enable",
"ToolTip": "Get Windows updates as soon as they're available for your device."
"ToolTip": "Get the latest updates as soon as they're available."
}
}
},

14
Wrapper/Localizations/ru-RU/tooltip_Windows_11.json

@ -489,6 +489,20 @@
}
}
},
{
"Region": "UI & Personalization",
"Function": "SearchHighlights",
"Arg": {
"Zero": {
"Tag": "Hide",
"ToolTip": "Скрыть главное в поиске."
},
"One": {
"Tag": "Show",
"ToolTip": "Показать главное в поиске (значение по умолчанию)."
}
}
},
{
"Region": "UI & Personalization",
"Function": "CopilotButton",

24
src/Sophia_Script_for_Windows_10/Functions.ps1

@ -165,6 +165,30 @@ $Parameters = @{
}
}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

740
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

File diff suppressed because it is too large

2
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -1012,7 +1012,7 @@ InstallVCRedist
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

24
src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1

@ -79,6 +79,30 @@ $Parameters = @{
{
$ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

417
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -445,6 +445,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -592,6 +595,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -606,6 +612,9 @@ public static string GetString(uint strId)
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -951,6 +960,9 @@ function script:Set-Policy
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3700,6 +3712,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3714,6 +3729,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3820,6 +3838,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3834,6 +3855,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4363,18 +4387,27 @@ function TempFolder
{
if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
# Stop OneDrive processes
Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
if (-not (Test-Path -Path $env:SystemDrive\Temp))
{
New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
@ -4478,12 +4511,18 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
# Stop OneDrive processes
Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
# Remove a symbolic link to the %SystemDrive%\Temp folder
if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
{
@ -5151,7 +5190,7 @@ function WindowsFeatures
} | ForEach-Object -Process {Get-WindowsOptionalFeature -FeatureName $_.FeatureName -Online}
$OFS = " "
if (-not ($Features))
if (-not $Features)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -5492,6 +5531,9 @@ function WindowsCapabilities
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5526,7 +5568,7 @@ function WindowsCapabilities
} | ForEach-Object -Process {Get-WindowsCapability -Name $_.Name -Online}
$OFS = " "
if (-not ($Capabilities))
if (-not $Capabilities)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -5856,6 +5898,9 @@ function IPv6Component
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5870,6 +5915,9 @@ function IPv6Component
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -8502,6 +8550,9 @@ function Import-Associations
{
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -8550,6 +8601,9 @@ function InstallVCRedist
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -8606,10 +8660,10 @@ function InstallVCRedist
<#
.SYNOPSIS
Install the latest .NET Desktop Runtime 6, 7 (x86/x64)
Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64)
.EXAMPLE
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
.LINK
https://dotnet.microsoft.com/en-us/download/dotnet
@ -8619,6 +8673,18 @@ function InstallVCRedist
#>
function InstallDotNetRuntimes
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
$Runtimes
)
try
{
# Check the internet connection
@ -8630,115 +8696,280 @@ function InstallDotNetRuntimes
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
foreach ($Runtime in $Runtimes)
{
switch ($Runtime)
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
NET6x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET6x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET7x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
NET7x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/8
# .NET Desktop Runtime 8 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 8 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# .NET Desktop Runtime 8 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# .NET Desktop Runtime 8 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
}
}
@ -8842,6 +9073,9 @@ function PreventEdgeShortcutCreation
if (($null -eq (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) -or ([System.Version](Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore).Version -lt [System.Version]"1.3.128.0"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -11810,6 +12044,9 @@ function UpdateLGPEPolicies
{
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1

@ -793,7 +793,7 @@ InstallVCRedist
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

24
src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1

@ -103,6 +103,30 @@ $Parameters = @{
}
}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

730
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -265,26 +265,6 @@ public static string GetString(uint strId)
exit
}
# Check for a pending reboot
$PendingActions = @(
# CBS pending
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootInProgress",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackagesPending",
# Windows Update pending
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired"
)
if (($PendingActions | Test-Path) -contains $true)
{
Write-Warning -Message $Localization.RebootPending
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -433,6 +413,26 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Check for a pending reboot
$PendingActions = @(
# CBS pending
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootInProgress",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackagesPending",
# Windows Update pending
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired"
)
if (($PendingActions | Test-Path) -contains $true)
{
Write-Warning -Message $Localization.RebootPending
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether the current module version is the latest one
try
{
@ -445,6 +445,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -592,6 +595,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -606,6 +612,9 @@ public static string GetString(uint strId)
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -951,6 +960,9 @@ function script:Set-Policy
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4072,6 +4084,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4086,6 +4101,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4192,6 +4210,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4206,6 +4227,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4735,18 +4759,27 @@ function TempFolder
{
if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
# Stop OneDrive processes
Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
if (-not (Test-Path -Path $env:SystemDrive\Temp))
{
New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
@ -4850,12 +4883,18 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
# Stop OneDrive processes
Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
# Remove a symbolic link to the %SystemDrive%\Temp folder
if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
{
@ -5524,7 +5563,7 @@ function WindowsFeatures
} | ForEach-Object -Process {Get-WindowsOptionalFeature -FeatureName $_.FeatureName -Online}
$OFS = " "
if (-not ($Features))
if (-not $Features)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -5880,6 +5919,9 @@ function WindowsCapabilities
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5914,7 +5956,7 @@ function WindowsCapabilities
} | ForEach-Object -Process {Get-WindowsCapability -Name $_.Name -Online}
$OFS = " "
if (-not ($Capabilities))
if (-not $Capabilities)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -6244,6 +6286,9 @@ function IPv6Component
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -6258,6 +6303,9 @@ function IPv6Component
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9129,6 +9177,9 @@ function Import-Associations
{
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9177,6 +9228,9 @@ function InstallVCRedist
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9233,10 +9287,10 @@ function InstallVCRedist
<#
.SYNOPSIS
Install the latest .NET Desktop Runtime 6, 7 (x86/x64)
Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64)
.EXAMPLE
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
.LINK
https://dotnet.microsoft.com/en-us/download/dotnet
@ -9246,6 +9300,18 @@ function InstallVCRedist
#>
function InstallDotNetRuntimes
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
$Runtimes
)
try
{
# Check the internet connection
@ -9257,115 +9323,280 @@ function InstallDotNetRuntimes
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
foreach ($Runtime in $Runtimes)
{
switch ($Runtime)
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
NET6x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET6x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET7x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
NET7x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/8
# .NET Desktop Runtime 8 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 8 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# .NET Desktop Runtime 8 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
# .NET Desktop Runtime 8 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
}
}
@ -9469,6 +9700,9 @@ function PreventEdgeShortcutCreation
if (($null -eq (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) -or ([System.Version](Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore).Version -lt [System.Version]"1.3.128.0"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9657,126 +9891,148 @@ function RegistryBackup
#>
function Install-WSL
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
try
{
# Check the internet connection
$Parameters = @{
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
$wsl = wsl --list --online
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = ($_ -split " ", 2 | Select-Object -Last 1).Trim()
"Alias" = ($_ -split " ", 2 | Select-Object -First 1).Trim()
return
}
}
Add-Type -AssemblyName PresentationCore, PresentationFramework
try
{
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
#region Variables
$CommandTag = $null
# https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json
# wsl --list --online relies on Internet connection too, so it's much convenient to parse DistributionInfo.json, rather than parse a cmd output
$Parameters = @{
Uri = "https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json"
UseBasicParsing = $true
Verbose = $true
}
(Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
}
}
#region XAML Markup
# The section defines the design of the upcoming dialog box
[xml]$XAML = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
</Style>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0, 0, 0, 2"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="20"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="IsEnabled" Value="False"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
Add-Type -AssemblyName PresentationCore, PresentationFramework
#region Variables
$CommandTag = $null
#region XAML Markup
# The section defines the design of the upcoming dialog box
[xml]$XAML = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="Window"
Title="WSL"
MinHeight="460" MinWidth="350"
SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
FontFamily="Candara" FontSize="16" ShowInTaskbar="True"
Background="#F1F1F1" Foreground="#262626">
<Window.Resources>
<Style TargetType="RadioButton">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10"/>
</Style>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0, 0, 0, 2"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="20"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="IsEnabled" Value="False"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="PanelContainer" Grid.Row="0"/>
<Button Name="ButtonInstall" Content="Install" Grid.Row="2"/>
</Grid>
</Window>
"@
#endregion XAML Markup
#endregion XAML Markup
$Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
}
$Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
$XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
}
$ButtonInstall.Content = $Localization.Install
#endregion Variables
$ButtonInstall.Content = $Localization.Install
#endregion Variables
#region Functions
function RadioButtonChecked
{
$Script:CommandTag = $_.OriginalSource.Tag
if (-not $ButtonInstall.IsEnabled)
{
$ButtonInstall.IsEnabled = $true
}
}
#region Functions
function RadioButtonChecked
{
$Script:CommandTag = $_.OriginalSource.Tag
if (-not $ButtonInstall.IsEnabled)
{
$ButtonInstall.IsEnabled = $true
}
}
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
function ButtonInstallClicked
{
Write-Warning -Message $Script:CommandTag
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
Start-Process -FilePath wsl.exe -ArgumentList "--install --distribution $Script:CommandTag" -Wait
$Form.Close()
$Form.Close()
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Receive updates for other Microsoft products when you update Windows
(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
# Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan
}
#endregion
# Check for updates
Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan
}
#endregion
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
foreach ($Distro in $Distros)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
}
$ButtonInstall.Add_Click({ButtonInstallClicked})
$ButtonInstall.Add_Click({ButtonInstallClicked})
#region Sendkey function
# Emulate the Backspace key sending to prevent the console window to freeze
Start-Sleep -Milliseconds 500
#region Sendkey function
# Emulate the Backspace key sending to prevent the console window to freeze
Start-Sleep -Milliseconds 500
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Windows.Forms
$Signature = @{
Namespace = "WinAPI"
Name = "ForegroundWindow"
Language = "CSharp"
MemberDefinition = @"
$Signature = @{
Namespace = "WinAPI"
Name = "ForegroundWindow"
Language = "CSharp"
MemberDefinition = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
@ -9784,32 +10040,45 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
"@
}
}
if (-not ("WinAPI.ForegroundWindow" -as [type]))
{
Add-Type @Signature
}
if (-not ("WinAPI.ForegroundWindow" -as [type]))
{
Add-Type @Signature
}
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
# Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
# Show window, if minimized
[WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
Start-Sleep -Seconds 1
Start-Sleep -Seconds 1
# Force move the console window to the foreground
[WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
# Force move the console window to the foreground
[WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
Start-Sleep -Seconds 1
Start-Sleep -Seconds 1
# Emulate the Backspace key sending
[System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
# Emulate the Backspace key sending
[System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
}
#endregion Sendkey function
# Force move the WPF form to the foreground
$Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://raw.githubusercontent.com")
Write-Error -Message ($Localization.NoResponse -f "https://raw.githubusercontent.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#endregion Sendkey function
# Force move the WPF form to the foreground
$Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
#endregion WSL
@ -12982,6 +13251,9 @@ function UpdateLGPEPolicies
{
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -891,7 +891,7 @@ InstallVCRedist
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

24
src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1

@ -172,6 +172,30 @@ $Parameters = @{
}
}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

740
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

File diff suppressed because it is too large

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -1021,7 +1021,7 @@ InstallVCRedist
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

24
src/Sophia_Script_for_Windows_11/Functions.ps1

@ -141,6 +141,30 @@ $Parameters = @{
}
}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{

542
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -121,6 +121,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -544,6 +547,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -686,6 +692,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -700,6 +709,9 @@ public static string GetString(uint strId)
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -906,6 +918,8 @@ public static string GetString(uint strId)
# Extract the localized "&Yes" string from shell32.dll
$Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "")
$Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll
$Script:Skip = [WinAPI.GetStr]::GetString(16956)
# Display a warning message about whether a user has customized the preset file
if ($Warning)
@ -1043,6 +1057,9 @@ function script:Set-Policy
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -2279,6 +2296,9 @@ function BrowsingHistory
if ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber -lt 23451)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3166,6 +3186,68 @@ function TaskbarSearch
}
}
<#
.SYNOPSIS
Search highlights
.PARAMETER Hide
Hide search highlights
.PARAMETER Show
Show search highlights
.EXAMPLE
SearchHighlights -Hide
.EXAMPLE
SearchHighlights -Show
.NOTES
Current user
#>
function SearchHighlights
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
)]
[switch]
$Hide,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
)]
[switch]
$Show
)
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null))
$DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null))
if (($BingSearchEnabled -eq 1) -or ($DisableSearchBoxSuggestions -eq 1))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force
}
"Show"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 1 -Force
}
}
}
<#
.SYNOPSIS
Copilot button on the taskbar
@ -4086,6 +4168,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4100,6 +4185,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4206,6 +4294,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4220,6 +4311,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4536,7 +4630,9 @@ function OneDrive
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if (-not $UninstallString)
{
# OneDrive is not installed
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4544,6 +4640,9 @@ function OneDrive
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4673,6 +4772,9 @@ public static bool MarkFileDelete (string sourcefile)
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if ($OneDrive)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4704,6 +4806,9 @@ public static bool MarkFileDelete (string sourcefile)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5039,12 +5144,18 @@ function TempFolder
{
if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5157,6 +5268,9 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5834,7 +5948,7 @@ function WindowsFeatures
} | ForEach-Object -Process {Get-WindowsOptionalFeature -FeatureName $_.FeatureName -Online}
$OFS = " "
if (-not ($Features))
if (-not $Features)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -6187,6 +6301,9 @@ function WindowsCapabilities
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -6221,7 +6338,7 @@ function WindowsCapabilities
} | ForEach-Object -Process {Get-WindowsCapability -Name $_.Name -Online}
$OFS = " "
if (-not ($Capabilities))
if (-not $Capabilities)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -6496,10 +6613,10 @@ function ActiveHours
Windows latest updates
.PARAMETER Disable
Do not get Windows updates as soon as they're available for your device
Do not get the latest updates as soon as they're available
.PARAMETER Enable
Get Windows updates as soon as they're available for your device
Get the latest updates as soon as they're available
.EXAMPLE
WindowsLatestUpdate -Disable
@ -6755,6 +6872,9 @@ function IPv6Component
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -6769,6 +6889,9 @@ function IPv6Component
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -7792,6 +7915,9 @@ function WinPrtScrFolder
Write-Warning -Message ($Localization.OneDriveWarning -f $MyInvocation.Line.Trim())
Write-Error -Message ($Localization.OneDriveWarning -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9542,6 +9668,9 @@ function Import-Associations
{
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9667,6 +9796,9 @@ function InstallVCRedist
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9723,10 +9855,10 @@ function InstallVCRedist
<#
.SYNOPSIS
Install the latest .NET Desktop Runtime 6, 7 (x86/x64)
Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64)
.EXAMPLE
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
.LINK
https://dotnet.microsoft.com/en-us/download/dotnet
@ -9736,6 +9868,18 @@ function InstallVCRedist
#>
function InstallDotNetRuntimes
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
$Runtimes
)
try
{
# Check the internet connection
@ -9747,118 +9891,285 @@ function InstallDotNetRuntimes
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
foreach ($Runtime in $Runtimes)
{
switch ($Runtime)
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
NET6x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET6x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET7x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
NET7x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/8
# .NET Desktop Runtime 8 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 8 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# .NET Desktop Runtime 8 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
# .NET Desktop Runtime 8 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
}
}
<#
.SYNOPSIS
Bypass RKN restrictins using antizapret.prostovpn.org proxies
@ -9948,6 +10259,9 @@ function Install-WSA
if (Get-AppxPackage -Name MicrosoftCorporationII.WindowsSubsystemForAndroid)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9971,6 +10285,9 @@ function Install-WSA
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10037,6 +10354,9 @@ function PreventEdgeShortcutCreation
if (($null -eq (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) -or ([System.Version](Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore).Version -lt [System.Version]"1.3.128.0"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10236,6 +10556,9 @@ function Install-WSL
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10833,7 +11156,8 @@ function UninstallUWPApps
[PSCustomObject]@{
Name = $AppxPackage.Name
PackageFullName = $AppxPackage.PackageFullName
DisplayName = $PackageId.DisplayName
# Sometimes there's more than one package presented in Windows with the same package name like {Microsoft Teams, Microsoft Teams} and we need to display one the first one a window
DisplayName = $PackageId.DisplayName | Select-Object -First 1
}
}
}
@ -13596,11 +13920,6 @@ function DNSoverHTTPS
$Disable
)
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain)
{
return
}
# Determining whether Hyper-V is enabled
# After enabling Hyper-V feature a virtual switch breing created, so we need to use different method to isolate the proper adapter
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
@ -13647,6 +13966,9 @@ function DNSoverHTTPS
{
{($_ -ne 203) -and ($_ -ne 29)}
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
@ -14524,15 +14846,13 @@ function OpenWindowsTerminalAdminContext
$Disable
)
if
(
# Check whether it is not blocked by policy
(-not (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore)) -and
# Check whether the package installed
(Get-AppxPackage -Name Microsoft.WindowsTerminal) -and
# Check whether Windows Terminal version is greater or equal than 1.11
([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11")
)
# Check whether it is not blocked by policy
$BlockGUID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore)
# Check whether the package installed
$TerminalInstalled = (Get-AppxPackage -Name Microsoft.WindowsTerminal)
# Check whether Windows Terminal version is greater or equal than 1.11
$TerminalInstalledVersion = ([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11")
if ((-not $BlockGUID) -and $TerminalInstalled -and $TerminalInstalledVersion)
{
if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"))
{
@ -14551,6 +14871,9 @@ function OpenWindowsTerminalAdminContext
Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -14663,6 +14986,9 @@ function UpdateLGPEPolicies
{
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}

18
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -402,6 +402,14 @@ TaskbarSearch -Hide
# Показать поле поиска на панели задач (значение по умолчанию)
# TaskbarSearch -SearchBox
# Hide search highlights
# Скрыть главное в поиске
SearchHighlights -Hide
# Show search highlights (default value)
# Показать главное в поиске (значение по умолчанию)
# SearchHighlights -Show
# Hide Copilot button on the taskbar
# Скрыть кнопку Copilot с панели задач
CopilotButton -Hide
@ -923,11 +931,11 @@ ActiveHours -Automatically
# Вручную изменять период активности для этого устройства на основе действий (значение по умолчанию)
# ActiveHours -Manually
# Do not get Windows updates as soon as they're available for your device (default value)
# Do not get the latest updates as soon as they're available (default value)
# Не получать последние обновления, как только они будут доступны (значение по умолчанию)
WindowsLatestUpdate -Disable
# Get Windows updates as soon as they're available for your device
# Get the latest updates as soon as they're available
# Получайте последние обновления, как только они будут доступны
# WindowsLatestUpdate -Enable
@ -971,12 +979,12 @@ DefaultTerminalApp -WindowsTerminal
InstallVCRedist
<#
Install the latest .NET Desktop Runtime 6, 7 (x86/x64)
Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64)
Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64)
Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64)
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

24
src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1

@ -148,6 +148,30 @@ $Parameters = @{
}
}
# If a module command is InstallDotNetRuntimes
if ($Command -eq "InstallDotNetRuntimes")
{
# Get all command arguments, excluding defaults
foreach ($ParameterSet in $ParameterSets.Name)
{
# If an argument is Runtimes
if ($ParameterSet -eq "Runtimes")
{
$ValidValues = ((Get-Command -Name InstallDotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues
foreach ($ValidValue in $ValidValues)
{
# The "InstallDotNetRuntimes -Runtimes <function>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
# The "InstallDotNetRuntimes -Runtimes <functions>" construction
"InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
continue
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{

540
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -102,6 +102,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -525,6 +528,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -672,6 +678,9 @@ public static string GetString(uint strId)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -686,6 +695,9 @@ public static string GetString(uint strId)
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -1031,6 +1043,9 @@ function script:Set-Policy
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -2267,6 +2282,9 @@ function BrowsingHistory
if ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber -lt 23451)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -3154,6 +3172,68 @@ function TaskbarSearch
}
}
<#
.SYNOPSIS
Search highlights
.PARAMETER Hide
Hide search highlights
.PARAMETER Show
Show search highlights
.EXAMPLE
SearchHighlights -Hide
.EXAMPLE
SearchHighlights -Show
.NOTES
Current user
#>
function SearchHighlights
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Hide"
)]
[switch]
$Hide,
[Parameter(
Mandatory = $true,
ParameterSetName = "Show"
)]
[switch]
$Show
)
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$BingSearchEnabled = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search", "BingSearchEnabled", $null))
$DisableSearchBoxSuggestions = ([Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableSearchBoxSuggestions", $null))
if (($BingSearchEnabled -eq 1) -or ($DisableSearchBoxSuggestions -eq 1))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
switch ($PSCmdlet.ParameterSetName)
{
"Hide"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 0 -Force
}
"Show"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SearchSettings -Name IsDynamicSearchBoxEnabled -PropertyType DWord -Value 1 -Force
}
}
}
<#
.SYNOPSIS
Copilot button on the taskbar
@ -4074,6 +4154,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4088,6 +4171,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4194,6 +4280,9 @@ function Cursors
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4208,6 +4297,9 @@ function Cursors
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4524,7 +4616,9 @@ function OneDrive
[string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
if (-not $UninstallString)
{
# OneDrive is not installed
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4532,6 +4626,9 @@ function OneDrive
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4661,6 +4758,9 @@ public static bool MarkFileDelete (string sourcefile)
$OneDrive = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -Force -ErrorAction Ignore
if ($OneDrive)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -4692,6 +4792,9 @@ public static bool MarkFileDelete (string sourcefile)
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5027,12 +5130,18 @@ function TempFolder
{
if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5145,6 +5254,9 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -5822,7 +5934,7 @@ function WindowsFeatures
} | ForEach-Object -Process {Get-WindowsOptionalFeature -FeatureName $_.FeatureName -Online}
$OFS = " "
if (-not ($Features))
if (-not $Features)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -6175,6 +6287,9 @@ function WindowsCapabilities
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -6209,7 +6324,7 @@ function WindowsCapabilities
} | ForEach-Object -Process {Get-WindowsCapability -Name $_.Name -Online}
$OFS = " "
if (-not ($Capabilities))
if (-not $Capabilities)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.NoData -Verbose
@ -6484,10 +6599,10 @@ function ActiveHours
Windows latest updates
.PARAMETER Disable
Do not get Windows updates as soon as they're available for your device
Do not get the latest updates as soon as they're available
.PARAMETER Enable
Get Windows updates as soon as they're available for your device
Get the latest updates as soon as they're available
.EXAMPLE
WindowsLatestUpdate -Disable
@ -6743,6 +6858,9 @@ function IPv6Component
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -6757,6 +6875,9 @@ function IPv6Component
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -7780,6 +7901,9 @@ function WinPrtScrFolder
Write-Warning -Message ($Localization.OneDriveWarning -f $MyInvocation.Line.Trim())
Write-Error -Message ($Localization.OneDriveWarning -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9530,6 +9654,9 @@ function Import-Associations
{
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9655,6 +9782,9 @@ function InstallVCRedist
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9711,10 +9841,10 @@ function InstallVCRedist
<#
.SYNOPSIS
Install the latest .NET Desktop Runtime 6, 7 (x86/x64)
Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64)
.EXAMPLE
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
.LINK
https://dotnet.microsoft.com/en-us/download/dotnet
@ -9724,6 +9854,18 @@ function InstallVCRedist
#>
function InstallDotNetRuntimes
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
$Runtimes
)
try
{
# Check the internet connection
@ -9735,115 +9877,280 @@ function InstallDotNetRuntimes
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
foreach ($Runtime in $Runtimes)
{
switch ($Runtime)
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
NET6x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 6 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET6x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# Install .NET Desktop Runtime 6
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/6.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# .NET Desktop Runtime 6 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
NET7x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
NET7x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x86
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/8
# .NET Desktop Runtime 8 x86
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# .NET Desktop Runtime 8 x86
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x86.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
# .NET Desktop Runtime 7 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
NET8x64
{
if ([System.Version](Get-AppxPackage -Name Microsoft.DesktopAppInstaller -ErrorAction Ignore).Version -ge [System.Version]"1.17")
{
# .NET Desktop Runtime 8 x64
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 8
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @{
Uri = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters)."latest-release"
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
# .NET Desktop Runtime 8 x64
$Parameters = @{
Uri = "https://dotnetcli.azureedge.net/dotnet/Runtime/$LatestRelease/dotnet-runtime-$LatestRelease-win-x64.exe"
OutFile = "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
}
}
@ -9936,6 +10243,9 @@ function Install-WSA
if (Get-AppxPackage -Name MicrosoftCorporationII.WindowsSubsystemForAndroid)
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -9959,6 +10269,9 @@ function Install-WSA
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10025,6 +10338,9 @@ function PreventEdgeShortcutCreation
if (($null -eq (Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore)) -or ([System.Version](Get-Package -Name "Microsoft Edge Update" -ProviderName Programs -ErrorAction Ignore).Version -lt [System.Version]"1.3.128.0"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10224,6 +10540,9 @@ function Install-WSL
}
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -10831,7 +11150,8 @@ function UninstallUWPApps
[PSCustomObject]@{
Name = $AppxPackage.Name
PackageFullName = $AppxPackage.PackageFullName
DisplayName = $PackageId.DisplayName
# Sometimes there's more than one package presented in Windows with the same package name like {Microsoft Teams, Microsoft Teams} and we need to display one the first one a window
DisplayName = $PackageId.DisplayName | Select-Object -First 1
}
}
}
@ -13604,11 +13924,6 @@ function DNSoverHTTPS
$Disable
)
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain)
{
return
}
# Determining whether Hyper-V is enabled
# After enabling Hyper-V feature a virtual switch breing created, so we need to use different method to isolate the proper adapter
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
@ -13655,6 +13970,9 @@ function DNSoverHTTPS
{
{($_ -ne 203) -and ($_ -ne 29)}
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
}
@ -14532,15 +14850,13 @@ function OpenWindowsTerminalAdminContext
$Disable
)
if
(
# Check whether it is not blocked by policy
(-not (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore)) -and
# Check whether the package installed
(Get-AppxPackage -Name Microsoft.WindowsTerminal) -and
# Check whether Windows Terminal version is greater or equal than 1.11
([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11")
)
# Check whether it is not blocked by policy
$BlockGUID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore)
# Check whether the package installed
$TerminalInstalled = (Get-AppxPackage -Name Microsoft.WindowsTerminal)
# Check whether Windows Terminal version is greater or equal than 1.11
$TerminalInstalledVersion = ([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11")
if ((-not $BlockGUID) -and $TerminalInstalled -and $TerminalInstalledVersion)
{
if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"))
{
@ -14553,12 +14869,15 @@ function OpenWindowsTerminalAdminContext
{
Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Raw | Test-Json -ErrorAction Stop
}
catch
catch [System.Exception]
{
Write-Error -Message ($Global:Error.Exception.Message | Select-Object -First 1) -ErrorAction SilentlyContinue
Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}
@ -14671,6 +14990,9 @@ function UpdateLGPEPolicies
{
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message $Localization.Skipped -Verbose
return
}

14
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -413,6 +413,14 @@ TaskbarSearch -Hide
# Показать поле поиска на панели задач (значение по умолчанию)
# TaskbarSearch -SearchBox
# Hide search highlights
# Скрыть главное в поиске
SearchHighlights -Hide
# Show search highlights (default value)
# Показать главное в поиске (значение по умолчанию)
# SearchHighlights -Show
# Hide Copilot button on the taskbar
# Скрыть кнопку Copilot с панели задач
CopilotButton -Hide
@ -934,11 +942,11 @@ ActiveHours -Automatically
# Вручную изменять период активности для этого устройства на основе действий (значение по умолчанию)
# ActiveHours -Manually
# Do not get Windows updates as soon as they're available for your device (default value)
# Do not get the latest updates as soon as they're available (default value)
# Не получать последние обновления, как только они будут доступны (значение по умолчанию)
WindowsLatestUpdate -Disable
# Get Windows updates as soon as they're available for your device
# Get the latest updates as soon as they're available
# Получайте последние обновления, как только они будут доступны
# WindowsLatestUpdate -Enable
@ -987,7 +995,7 @@ InstallVCRedist
https://dotnet.microsoft.com/en-us/download/dotnet
#>
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86, NET6x64, NET7x86, NET7x64, NET8x86, NET8x64
# Enable proxying only blocked sites from the unified registry of Roskomnadzor. The function is applicable for Russia only
# Включить проксирование только заблокированных сайтов из единого реестра Роскомнадзора. Функция применима только для России

Loading…
Cancel
Save