@ -265,26 +265,6 @@ public static string GetString(uint strId)
exit
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
#region Defender checks
# Check whether necessary Microsoft Defender components exists
# Check whether necessary Microsoft Defender components exists
$Files = @ (
$Files = @ (
@ -433,6 +413,26 @@ public static string GetString(uint strId)
}
}
#endregion Defender checks
#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
# Check whether the current module version is the latest one
try
try
{
{
@ -445,6 +445,9 @@ public static string GetString(uint strId)
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -592,6 +595,9 @@ public static string GetString(uint strId)
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -606,6 +612,9 @@ public static string GetString(uint strId)
}
}
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -951,6 +960,9 @@ function script:Set-Policy
if ( -not ( Test-Path -Path " $ env:SystemRoot\System32\gpedit.msc " ) )
if ( -not ( Test-Path -Path " $ env:SystemRoot\System32\gpedit.msc " ) )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -4072,6 +4084,9 @@ function Cursors
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -4086,6 +4101,9 @@ function Cursors
}
}
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -4192,6 +4210,9 @@ function Cursors
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -4206,6 +4227,9 @@ function Cursors
}
}
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -4735,18 +4759,27 @@ function TempFolder
{
{
if ( ( Get-LocalUser | Where-Object -FilterScript { $_ . Enabled } ) . Count -gt 1 )
if ( ( Get-LocalUser | Where-Object -FilterScript { $_ . Enabled } ) . Count -gt 1 )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# 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 " )
if ( ( Get-Item -Path $env:TEMP ) . FullName -eq " $ env:SystemDrive\Temp " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
# Restart the Printer Spooler service (Spooler)
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
Restart-Service -Name Spooler -Force
# Stop OneDrive processes
Stop-Process -Name OneDrive , FileCoAuth -Force -ErrorAction Ignore
if ( -not ( Test-Path -Path $env:SystemDrive \ Temp ) )
if ( -not ( Test-Path -Path $env:SystemDrive \ Temp ) )
{
{
New-Item -Path $env:SystemDrive \ Temp -ItemType Directory -Force
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
# 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 " )
if ( ( Get-Item -Path $env:TEMP ) . FullName -eq " $ env:LOCALAPPDATA\Temp " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
# Restart the Printer Spooler service (Spooler)
# Restart the Printer Spooler service (Spooler)
Restart-Service -Name Spooler -Force
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
# 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 " } )
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 }
} | ForEach-Object -Process { Get-WindowsOptionalFeature -FeatureName $_ . FeatureName -Online }
$OFS = " "
$OFS = " "
if ( -not ( $Features ) )
if ( -not $Features )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . NoData -Verbose
Write-Verbose -Message $Localization . NoData -Verbose
@ -5880,6 +5919,9 @@ function WindowsCapabilities
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -5914,7 +5956,7 @@ function WindowsCapabilities
} | ForEach-Object -Process { Get-WindowsCapability -Name $_ . Name -Online }
} | ForEach-Object -Process { Get-WindowsCapability -Name $_ . Name -Online }
$OFS = " "
$OFS = " "
if ( -not ( $Capabilities ) )
if ( -not $Capabilities )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . NoData -Verbose
Write-Verbose -Message $Localization . NoData -Verbose
@ -6244,6 +6286,9 @@ function IPv6Component
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -6258,6 +6303,9 @@ function IPv6Component
}
}
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
if ( -not ( Invoke-WebRequest @Parameters ) . StatusDescription )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -9129,6 +9177,9 @@ function Import-Associations
{
{
Write-Error -Message ( $Localization . RestartFunction -f $MyInvocation . Line . Trim ( ) ) -ErrorAction SilentlyContinue
Write-Error -Message ( $Localization . RestartFunction -f $MyInvocation . Line . Trim ( ) ) -ErrorAction SilentlyContinue
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -9177,6 +9228,9 @@ function InstallVCRedist
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}
@ -9233,10 +9287,10 @@ function InstallVCRedist
<#
<#
. SYNOPSIS
. SYNOPSIS
Install the latest . NET Desktop Runtime 6 , 7 ( x86 / x64 )
Install the latest . NET Desktop Runtime 6 , 7 , 8 ( x86 / x64 )
. EXAMPLE
. EXAMPLE
InstallDotNetRuntimes
InstallDotNetRuntimes -Runtimes NET6x86 , NET6x64 , NET7x86 , NET7x64 , NET8x86 , NET8x64
. LINK
. LINK
https : / / dotnet . microsoft . com / en-us / download / dotnet
https : / / dotnet . microsoft . com / en-us / download / dotnet
@ -9246,6 +9300,18 @@ function InstallVCRedist
#>
#>
function InstallDotNetRuntimes
function InstallDotNetRuntimes
{
{
[ CmdletBinding ( ) ]
param
(
[ Parameter (
Mandatory = $false ,
ParameterSetName = " Channels "
) ]
[ ValidateSet ( " NET6x86 " , " NET6x64 " , " NET7x86 " , " NET7x64 " , " NET8x86 " , " NET8x64 " ) ]
[string[]]
$Runtimes
)
try
try
{
{
# Check the internet connection
# Check the internet connection
@ -9257,115 +9323,280 @@ function InstallDotNetRuntimes
}
}
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
if ( ( Resolve-DnsName @Parameters ) . IPAddress -notcontains " 131.107.255.255 " )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
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
NET6x86
# .NET Desktop Runtime 6 x86
{
winget install - -id = Microsoft . DotNet . DesktopRuntime . 6 - -architecture x86 - -exact - -force - -accept -source -agreements
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore ) . Version -ge [System.Version] " 1.17 " )
# .NET Desktop Runtime 6 x64
{
winget install - -id = Microsoft . DotNet . DesktopRuntime . 6 - -architecture x64 - -exact - -force - -accept -source -agreements
# 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
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# .NET Desktop Runtime 7 x86
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
winget install - -id = Microsoft . DotNet . DesktopRuntime . 7 - -architecture x86 - -exact - -force - -accept -source -agreements
}
# .NET Desktop Runtime 7 x64
else
winget install - -id = Microsoft . DotNet . DesktopRuntime . 7 - -architecture x64 - -exact - -force - -accept -source -agreements
{
# 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
# .NET Desktop Runtime 6 x86
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
$Parameters = @ {
}
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x86.exe "
else
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe "
{
UseBasicParsing = $true
# Install .NET Desktop Runtime 6
Verbose = $true
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
}
$Parameters = @ {
Invoke-WebRequest @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
Start-Process -FilePath " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe " -ArgumentList " /install /passive /norestart " -Wait
$Parameters = @ {
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x86.exe "
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe "
$Paths = @ (
UseBasicParsing = $true
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe " ,
Verbose = $true
" $ 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
# .NET Desktop Runtime 6 x64
$Parameters = @ {
$Parameters = @ {
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x64.exe "
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x64.exe "
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe "
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe "
UseBasicParsing = $true
UseBasicParsing = $true
Verbose = $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
# .NET Desktop Runtime 7 x86
$Paths = @ (
$Parameters = @ {
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe " ,
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x86.exe "
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe " ,
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe "
" $ env:TEMP\Microsoft_.NET_Runtime*.log "
UseBasicParsing = $true
)
Verbose = $true
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
Invoke-WebRequest @Parameters
# .NET Desktop Runtime 7
Start-Process -FilePath " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe " -ArgumentList " /install /passive /norestart " -Wait
# 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 "
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
Verbose = $true
$Paths = @ (
UseBasicParsing = $true
" $ 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 "
NET7x64
$DownloadsFolder = Get-ItemPropertyValue -Path " HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders " -Name " {374DE290-123F-4565-9164-39C4925E467B} "
{
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
# .NET Desktop Runtime 8 x64
$Paths = @ (
$Parameters = @ {
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x86.exe " ,
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x64.exe "
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe " ,
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe "
" $ env:TEMP\Microsoft_.NET_Runtime*.log "
UseBasicParsing = $true
)
Verbose = $true
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
Invoke-WebRequest @Parameters
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization . NoInternetConnection
Write-Error -Message $Localization . NoInternetConnection -ErrorAction SilentlyContinue
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 " ) )
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
return
}
}
@ -9657,126 +9891,148 @@ function RegistryBackup
#>
#>
function Install-WSL
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
return
# 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 ( )
}
}
}
Add-Type -AssemblyName PresentationCore , PresentationFramework
try
{
[System.Console] :: OutputEncoding = [System.Text.Encoding] :: Unicode
#region Variables
# https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json
$CommandTag = $null
# 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
Add-Type -AssemblyName PresentationCore , PresentationFramework
# The section defines the design of the upcoming dialog box
[xml] $XAML = @ "
#region Variables
< Window
$CommandTag = $null
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns : x = " http://schemas.microsoft.com/winfx/2006/xaml "
#region XAML Markup
Name = " Window "
# The section defines the design of the upcoming dialog box
Title = " WSL "
[xml] $XAML = @ "
MinHeight = " 460 " MinWidth = " 350 "
< Window
SizeToContent = " WidthAndHeight " WindowStartupLocation = " CenterScreen "
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
TextOptions . TextFormattingMode = " Display " SnapsToDevicePixels = " True "
xmlns : x = " http://schemas.microsoft.com/winfx/2006/xaml "
FontFamily = " Candara " FontSize = " 16 " ShowInTaskbar = " True "
Name = " Window "
Background = " #F1F1F1 " Foreground = " #262626 " >
Title = " WSL "
< Window . Resources >
MinHeight = " 460 " MinWidth = " 350 "
< Style TargetType = " RadioButton " >
SizeToContent = " WidthAndHeight " WindowStartupLocation = " CenterScreen "
< Setter Property = " VerticalAlignment " Value = " Center " / >
TextOptions . TextFormattingMode = " Display " SnapsToDevicePixels = " True "
< Setter Property = " Margin " Value = " 10 " / >
FontFamily = " Candara " FontSize = " 16 " ShowInTaskbar = " True "
< / Style >
Background = " #F1F1F1 " Foreground = " #262626 " >
< Style TargetType = " TextBlock " >
< Window . Resources >
< Setter Property = " VerticalAlignment " Value = " Center " / >
< Style TargetType = " RadioButton " >
< Setter Property = " Margin " Value = " 0, 0, 0, 2 " / >
< Setter Property = " VerticalAlignment " Value = " Center " / >
< / Style >
< Setter Property = " Margin " Value = " 10 " / >
< Style TargetType = " Button " >
< / Style >
< Setter Property = " Margin " Value = " 20 " / >
< Style TargetType = " TextBlock " >
< Setter Property = " Padding " Value = " 10 " / >
< Setter Property = " VerticalAlignment " Value = " Center " / >
< Setter Property = " IsEnabled " Value = " False " / >
< Setter Property = " Margin " Value = " 0, 0, 0, 2 " / >
< / Style >
< / Style >
< / Window . Resources >
< Style TargetType = " Button " >
< Grid >
< Setter Property = " Margin " Value = " 20 " / >
< Grid . RowDefinitions >
< Setter Property = " Padding " Value = " 10 " / >
< RowDefinition Height = " * " / >
< Setter Property = " IsEnabled " Value = " False " / >
< RowDefinition Height = " Auto " / >
< / Style >
< / Grid . RowDefinitions >
< / Window . Resources >
< StackPanel Name = " PanelContainer " Grid . Row = " 0 " / >
< Grid >
< Button Name = " ButtonInstall " Content = " Install " Grid . Row = " 2 " / >
< Grid . RowDefinitions >
< / Grid >
< RowDefinition Height = " * " / >
< / Window >
< 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 ) )
$Form = [Windows.Markup.XamlReader] :: Load ( ( New-Object -TypeName System . Xml . XmlNodeReader -ArgumentList $XAML ) )
$XAML . SelectNodes ( " //*[@*[contains(translate(name(.),'n','N'),'Name')]] " ) | ForEach-Object -Process {
$XAML . SelectNodes ( " //*[@*[contains(translate(name(.),'n','N'),'Name')]] " ) | ForEach-Object -Process {
Set-Variable -Name ( $_ . Name ) -Value $Form . FindName ( $_ . Name )
Set-Variable -Name ( $_ . Name ) -Value $Form . FindName ( $_ . Name )
}
}
$ButtonInstall . Content = $Localization . Install
$ButtonInstall . Content = $Localization . Install
#endregion Variables
#endregion Variables
#region Functions
#region Functions
function RadioButtonChecked
function RadioButtonChecked
{
{
$Script:CommandTag = $_ . OriginalSource . Tag
$Script:CommandTag = $_ . OriginalSource . Tag
if ( -not $ButtonInstall . IsEnabled )
if ( -not $ButtonInstall . IsEnabled )
{
{
$ButtonInstall . IsEnabled = $true
$ButtonInstall . IsEnabled = $true
}
}
}
}
function ButtonInstallClicked
function ButtonInstallClicked
{
{
Write-Warning -Message $Script:CommandTag
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
# Receive updates for other Microsoft products when you update Windows
( New-Object -ComObject Microsoft . Update . ServiceManager ) . AddService2 ( " 7971f918-a847-4430-9279-4a52d1efe18d " , 7 , " " )
( New-Object -ComObject Microsoft . Update . ServiceManager ) . AddService2 ( " 7971f918-a847-4430-9279-4a52d1efe18d " , 7 , " " )
# Check for updates
# Check for updates
Start-Process -FilePath " $ env:SystemRoot\System32\UsoClient.exe " -ArgumentList StartInteractiveScan
Start-Process -FilePath " $ env:SystemRoot\System32\UsoClient.exe " -ArgumentList StartInteractiveScan
}
}
#endregion
#endregion
foreach ( $Distro in $Distros )
foreach ( $Distro in $Distros )
{
{
$Panel = New-Object -TypeName System . Windows . Controls . StackPanel
$Panel = New-Object -TypeName System . Windows . Controls . StackPanel
$RadioButton = New-Object -TypeName System . Windows . Controls . RadioButton
$RadioButton = New-Object -TypeName System . Windows . Controls . RadioButton
$TextBlock = New-Object -TypeName System . Windows . Controls . TextBlock
$TextBlock = New-Object -TypeName System . Windows . Controls . TextBlock
$Panel . Orientation = " Horizontal "
$Panel . Orientation = " Horizontal "
$RadioButton . GroupName = " WslDistro "
$RadioButton . GroupName = " WslDistro "
$RadioButton . Tag = $Distro . Alias
$RadioButton . Tag = $Distro . Alias
$RadioButton . Add_Checked ( { RadioButtonChecked } )
$RadioButton . Add_Checked ( { RadioButtonChecked } )
$TextBlock . Text = $Distro . Distro
$TextBlock . Text = $Distro . Distro
$Panel . Children . Add ( $RadioButton ) | Out-Null
$Panel . Children . Add ( $RadioButton ) | Out-Null
$Panel . Children . Add ( $TextBlock ) | Out-Null
$Panel . Children . Add ( $TextBlock ) | Out-Null
$PanelContainer . Children . Add ( $Panel ) | Out-Null
$PanelContainer . Children . Add ( $Panel ) | Out-Null
}
}
$ButtonInstall . Add_Click ( { ButtonInstallClicked } )
$ButtonInstall . Add_Click ( { ButtonInstallClicked } )
#region Sendkey function
#region Sendkey function
# Emulate the Backspace key sending to prevent the console window to freeze
# Emulate the Backspace key sending to prevent the console window to freeze
Start-Sleep -Milliseconds 500
Start-Sleep -Milliseconds 500
Add-Type -AssemblyName System . Windows . Forms
Add-Type -AssemblyName System . Windows . Forms
$Signature = @ {
$Signature = @ {
Namespace = " WinAPI "
Namespace = " WinAPI "
Name = " ForegroundWindow "
Name = " ForegroundWindow "
Language = " CSharp "
Language = " CSharp "
MemberDefinition = @ "
MemberDefinition = @ "
[ DllImport ( " user32.dll " ) ]
[ DllImport ( " user32.dll " ) ]
public static extern bool ShowWindowAsync ( IntPtr hWnd , int nCmdShow ) ;
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 ) ]
[ return : MarshalAs ( UnmanagedType . Bool ) ]
public static extern bool SetForegroundWindow ( IntPtr hWnd ) ;
public static extern bool SetForegroundWindow ( IntPtr hWnd ) ;
" @
" @
}
}
if ( -not ( " WinAPI.ForegroundWindow " -as [type] ) )
if ( -not ( " WinAPI.ForegroundWindow " -as [type] ) )
{
{
Add-Type @Signature
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 {
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
# Show window, if minimized
[WinAPI.ForegroundWindow] :: ShowWindowAsync ( $_ . MainWindowHandle , 10 )
[WinAPI.ForegroundWindow] :: ShowWindowAsync ( $_ . MainWindowHandle , 10 )
Start-Sleep -Seconds 1
Start-Sleep -Seconds 1
# Force move the console window to the foreground
# Force move the console window to the foreground
[WinAPI.ForegroundWindow] :: SetForegroundWindow ( $_ . MainWindowHandle )
[WinAPI.ForegroundWindow] :: SetForegroundWindow ( $_ . MainWindowHandle )
Start-Sleep -Seconds 1
Start-Sleep -Seconds 1
# Emulate the Backspace key sending
# Emulate the Backspace key sending
[System.Windows.Forms.SendKeys] :: SendWait ( " {BACKSPACE 1} " )
[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
#endregion WSL
@ -12982,6 +13251,9 @@ function UpdateLGPEPolicies
{
{
if ( -not ( Test-Path -Path " $ env:SystemRoot\System32\gpedit.msc " ) )
if ( -not ( Test-Path -Path " $ env:SystemRoot\System32\gpedit.msc " ) )
{
{
Write-Information -MessageData " " -InformationAction Continue
Write-Verbose -Message $Localization . Skipped -Verbose
return
return
}
}