diff --git a/Wrapper/Config/config_Windows_11.json b/Wrapper/Config/config_Windows_11.json index 79c3f245..a725f518 100644 --- a/Wrapper/Config/config_Windows_11.json +++ b/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", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json index 12a233d8..66f0f9c9 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json +++ b/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." } } }, diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_11.json b/Wrapper/Localizations/en-US/tooltip_Windows_11.json index 52dd678c..f56cdee8 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_11.json +++ b/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." } } }, diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json index 4a27d974..638e7a2b 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json +++ b/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", diff --git a/src/Sophia_Script_for_Windows_10/Functions.ps1 b/src/Sophia_Script_for_Windows_10/Functions.ps1 index eec0f4df..bfae43e6 100644 --- a/src/Sophia_Script_for_Windows_10/Functions.ps1 +++ b/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 " construction + "InstallDotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} + } + + # The "InstallDotNetRuntimes -Runtimes " 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") { diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 4dd73500..e74dd5fd 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -122,6 +122,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 } @@ -568,6 +571,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 } @@ -710,6 +716,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 } @@ -724,6 +733,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 } @@ -1069,6 +1081,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 } @@ -4765,6 +4780,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 } @@ -4779,6 +4797,9 @@ function Cursors } if (-not (Invoke-WebRequest @Parameters).StatusDescription) { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + return } @@ -4885,6 +4906,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 } @@ -4899,6 +4923,9 @@ function Cursors } if (-not (Invoke-WebRequest @Parameters).StatusDescription) { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + return } @@ -5215,7 +5242,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 } @@ -5223,6 +5252,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 } @@ -5352,6 +5384,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 } @@ -5383,6 +5418,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 } @@ -5718,12 +5756,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 } @@ -5836,6 +5880,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 } @@ -6513,7 +6560,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 @@ -6869,6 +6916,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 } @@ -6903,7 +6953,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 @@ -7233,6 +7283,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 } @@ -7247,6 +7300,9 @@ function IPv6Component } if (-not (Invoke-WebRequest @Parameters).StatusDescription) { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + return } @@ -8270,6 +8326,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 } @@ -10224,6 +10283,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 } @@ -10320,6 +10382,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 } @@ -10376,10 +10441,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 @@ -10389,6 +10454,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 @@ -10400,115 +10477,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 + + # 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 + } + + } + } } } @@ -10612,6 +10854,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 } @@ -10800,126 +11045,148 @@ function RegistryBackup #> function Install-WSL { - [System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode - - $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() + 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 - Add-Type -AssemblyName PresentationCore, PresentationFramework + return + } - #region Variables - $CommandTag = $null + try + { + [System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode - #region XAML Markup - # The section defines the design of the upcoming dialog box - [xml]$XAML = @" - - - - - - - - - - - - -