Browse Source

Re-arranged startup checks

master
Dmitry Nefedov 10 months ago
parent
commit
316ddfd8dc
  1. 2
      src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1
  2. 218
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  3. 6
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  4. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1
  5. 194
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  6. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1
  7. 168
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  8. 4
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  9. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1
  10. 228
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  11. 6
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  12. 2
      src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1
  13. 218
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  14. 4
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  15. 2
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1
  16. 228
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  17. 4
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

2
src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1

@ -13,7 +13,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

218
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -89,7 +89,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
# Check whether Microsoft Edge as being a system component was removed by harmful tweakers
if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
@ -178,7 +178,7 @@ public static string GetString(uint strId)
}
}
# Detect the OS bitness
# Detect Windows bitness
if (-not [System.Environment]::Is64BitOperatingSystem)
{
Write-Warning -Message $Localization.UnsupportedOSBitness
@ -189,17 +189,6 @@ public static string GetString(uint strId)
exit
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -305,7 +294,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -316,42 +305,33 @@ public static string GetString(uint strId)
exit
}
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Warning -Message $Localization.Bin
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
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)
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
Write-Warning -Message $Localization.RebootPending
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -359,7 +339,7 @@ public static string GetString(uint strId)
exit
}
# Check if Microsoft Store being an important system component was removed
# Check whether Microsoft Store being an important system component was removed
if (-not (Get-AppxPackage -Name Microsoft.WindowsStore))
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store")
@ -370,55 +350,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -503,7 +434,7 @@ public static string GetString(uint strId)
# Defender is a currently used AV. Continue...
$Script:DefenderProductState = $true
# Check if Windows is Enterprise for Chineese Goverment which doesn't have Defender
# Check whether Windows is Enterprise for Chineese Goverment which doesn't have Defender
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG")
{
# Defender is a currently used AV. Continue...
@ -579,7 +510,88 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# 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
{
# 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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
{($_ -lt 19045) -or ($_ -gt 19045)}
@ -596,7 +608,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3803)
{
# Check whether the OS minor build version is 3803 minimum
# Check whether Windows minor build version is 3803 minimum
# https://learn.microsoft.com/en-us/windows/release-health/release-information#windows-10-current-versions-by-servicing-option
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -729,7 +741,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -5167,7 +5179,7 @@ function OneDrive
return
}
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -8211,7 +8223,7 @@ function WinPrtScrFolder
$Default
)
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -8293,7 +8305,7 @@ function WinPrtScrFolder
RecommendedTroubleshooting -Default
.NOTES
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
.NOTES
Machine-wide
@ -8337,7 +8349,7 @@ function RecommendedTroubleshooting
}
}
# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
# Set Windows level of diagnostic data gathering to "Optional diagnostic data"
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
@ -10213,7 +10225,7 @@ function Import-Associations
https://support.microsoft.com/en-us/windows/how-to-use-the-pc-health-check-app-9c8abd9b-03ba-4e67-81ef-36f37caa7844
.NOTES
This application is installed with the KB5005463 update to check if PC meets the system requirements of Windows 11
This application is installed with the KB5005463 update to Check whether PC meets the system requirements of Windows 11
.NOTES
Machine-wide
@ -11048,7 +11060,7 @@ function PinToStart
# Extract the localized "Devices and Printers" string from shell32.dll
$DevicesPrinters = [WinAPI.GetStr]::GetString(30493)
# Check if an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
# Check whether an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"})
{
# Create the old-style "Devices and Printers" shortcut in the Start menu
@ -12635,7 +12647,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -13060,7 +13072,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -13364,7 +13376,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -15434,7 +15446,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -15492,7 +15504,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -15662,7 +15674,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

6
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -823,7 +823,7 @@ WinPrtScrFolder -Desktop
<#
Run troubleshooter automatically, then notify me
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
Автоматически запускать средства устранения неполадок, а затем уведомлять
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -832,7 +832,7 @@ RecommendedTroubleshooting -Automatically
<#
Ask me before running troubleshooter (default value)
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data"
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data"
Спрашивать перед запуском средств устранения неполадок (значение по умолчанию)
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -976,7 +976,7 @@ WindowsLatestUpdate -Disable
<#
Uninstall the "PC Health Check" app and prevent it from installing in the future
This application is installed with the KB5005463 update to check if PC meets the system requirements of Windows 11
This application is installed with the KB5005463 update to Check whether PC meets the system requirements of Windows 11
Удалить приложение "Проверка работоспособности ПК Windows" и заблокировать его установку в будущем
Данное приложение устанавливается обновлением KB5005463 для проверки соответствия компьютера системным требованиям Windows 11

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1

@ -13,7 +13,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

194
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -89,7 +89,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Detect the OS bitness
# Detect Windows bitness
if (-not [System.Environment]::Is64BitOperatingSystem)
{
Write-Warning -Message $Localization.UnsupportedOSBitness
@ -100,17 +100,6 @@ public static string GetString(uint strId)
exit
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -216,7 +205,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -227,31 +216,22 @@ public static string GetString(uint strId)
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
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)
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
Write-Warning -Message $Localization.RebootPending
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -259,55 +239,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -456,7 +387,88 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# 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
{
# 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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
if ((Get-WindowsEdition -Online).Edition -notmatch "EnterpriseS")
{
Write-Warning -Message $Localization.UnsupportedOSBuild
@ -484,7 +496,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 5206)
{
# Check whether the OS minor build version is 5206 minimum
# Check whether Windows minor build version is 5206 minimum
# https://learn.microsoft.com/en-us/windows/release-health/release-information#windows-10-current-versions-by-servicing-option
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -614,7 +626,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -9163,7 +9175,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -9588,7 +9600,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -9892,7 +9904,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -11739,7 +11751,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -11797,7 +11809,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -11957,7 +11969,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1

@ -13,7 +13,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

168
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -89,7 +89,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Detect the OS bitness
# Detect Windows bitness
if (-not [System.Environment]::Is64BitOperatingSystem)
{
Write-Warning -Message $Localization.UnsupportedOSBitness
@ -100,17 +100,6 @@ public static string GetString(uint strId)
exit
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -216,7 +205,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -227,12 +216,23 @@ public static string GetString(uint strId)
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message $Localization.Bin
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -259,55 +259,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -456,7 +407,68 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# Check whether the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
if ((Get-WindowsEdition -Online).Edition -notmatch "EnterpriseS")
{
Write-Warning -Message $Localization.UnsupportedOSBuild
@ -484,7 +496,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3803)
{
# Check whether the OS minor build version is 3803 minimum
# Check whether Windows minor build version is 3803 minimum
# https://learn.microsoft.com/en-us/windows/release-health/release-information#windows-10-current-versions-by-servicing-option
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -614,7 +626,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -7252,7 +7264,7 @@ function WinPrtScrFolder
RecommendedTroubleshooting -Default
.NOTES
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
.NOTES
Machine-wide
@ -7296,7 +7308,7 @@ function RecommendedTroubleshooting
}
}
# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
# Set Windows level of diagnostic data gathering to "Optional diagnostic data"
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
@ -9908,7 +9920,7 @@ function PinToStart
# Extract the localized "Devices and Printers" string from shell32.dll
$DevicesPrinters = [WinAPI.GetStr]::GetString(30493)
# Check if an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
# Check whether an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"})
{
# Create the old-style "Devices and Printers" shortcut in the Start menu
@ -10281,7 +10293,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -10706,7 +10718,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -11010,7 +11022,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -12911,7 +12923,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -12969,7 +12981,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -13129,7 +13141,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

4
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -721,7 +721,7 @@ WinPrtScrFolder -Desktop
<#
Run troubleshooter automatically, then notify me
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
Автоматически запускать средства устранения неполадок, а затем уведомлять
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -730,7 +730,7 @@ RecommendedTroubleshooting -Automatically
<#
Ask me before running troubleshooter (default value)
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data"
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data"
Спрашивать перед запуском средств устранения неполадок (значение по умолчанию)
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1

@ -13,7 +13,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

228
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -85,7 +85,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
# Check whether Microsoft Edge as being a system component was removed by harmful tweakers
if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
@ -174,7 +174,7 @@ public static string GetString(uint strId)
}
}
# Detect the OS bitness
# Detect Windows bitness
if (-not [System.Environment]::Is64BitOperatingSystem)
{
Write-Warning -Message $Localization.UnsupportedOSBitness
@ -185,17 +185,6 @@ public static string GetString(uint strId)
exit
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -301,7 +290,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -312,47 +301,33 @@ public static string GetString(uint strId)
exit
}
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check whether all necessary files exist in the bin folder
$Files = @(
"$PSScriptRoot\..\bin\LGPO.exe",
"$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll",
"$PSScriptRoot\..\bin\WinRT.Runtime.dll"
)
if (($Files | Test-Path) -contains $false)
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Warning -Message $Localization.Bin
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
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)
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
Write-Warning -Message $Localization.RebootPending
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -360,7 +335,7 @@ public static string GetString(uint strId)
exit
}
# Check if Microsoft Store being an important system component was removed
# Check whether Microsoft Store being an important system component was removed
if (-not (Get-AppxPackage -Name Microsoft.WindowsStore))
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store")
@ -371,55 +346,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -504,7 +430,7 @@ public static string GetString(uint strId)
# Defender is a currently used AV. Continue...
$Script:DefenderProductState = $true
# Check if Windows is Enterprise for Chineese Goverment which doesn't have Defender
# Check whether Windows is Enterprise for Chineese Goverment which doesn't have Defender
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name EditionID) -ne "EnterpriseG")
{
# Defender is a currently used AV. Continue...
@ -580,7 +506,93 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# 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
{
# 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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether all necessary files exist in the bin folder
$Files = @(
"$PSScriptRoot\..\bin\LGPO.exe",
"$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll",
"$PSScriptRoot\..\bin\WinRT.Runtime.dll"
)
if (($Files | Test-Path) -contains $false)
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
{($_ -lt 19045) -or ($_ -gt 19045)}
@ -597,7 +609,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3803)
{
# Check whether the OS minor build version is 3803 minimum
# Check whether Windows minor build version is 3803 minimum
# https://learn.microsoft.com/en-us/windows/release-health/release-information#windows-10-current-versions-by-servicing-option
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -730,7 +742,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -5171,7 +5183,7 @@ function OneDrive
return
}
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -8215,7 +8227,7 @@ function WinPrtScrFolder
$Default
)
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -8297,7 +8309,7 @@ function WinPrtScrFolder
RecommendedTroubleshooting -Default
.NOTES
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
.NOTES
Machine-wide
@ -8341,7 +8353,7 @@ function RecommendedTroubleshooting
}
}
# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
# Set Windows level of diagnostic data gathering to "Optional diagnostic data"
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
@ -10217,7 +10229,7 @@ function Import-Associations
https://support.microsoft.com/en-us/windows/how-to-use-the-pc-health-check-app-9c8abd9b-03ba-4e67-81ef-36f37caa7844
.NOTES
This application is installed with the KB5005463 update to check if PC meets the system requirements of Windows 11
This application is installed with the KB5005463 update to Check whether PC meets the system requirements of Windows 11
.NOTES
Machine-wide
@ -11052,7 +11064,7 @@ function PinToStart
# Extract the localized "Devices and Printers" string from shell32.dll
$DevicesPrinters = [WinAPI.GetStr]::GetString(30493)
# Check if an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
# Check whether an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created
if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"})
{
# Create the old-style "Devices and Printers" shortcut in the Start menu
@ -12659,7 +12671,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -13084,7 +13096,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -13388,7 +13400,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -15458,7 +15470,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -15516,7 +15528,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -15686,7 +15698,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

6
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -832,7 +832,7 @@ WinPrtScrFolder -Desktop
<#
Run troubleshooter automatically, then notify me
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
Автоматически запускать средства устранения неполадок, а затем уведомлять
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -841,7 +841,7 @@ RecommendedTroubleshooting -Automatically
<#
Ask me before running troubleshooter (default value)
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data"
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data"
Спрашивать перед запуском средств устранения неполадок (значение по умолчанию)
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -985,7 +985,7 @@ WindowsLatestUpdate -Disable
<#
Uninstall the "PC Health Check" app and prevent it from installing in the future
This application is installed with the KB5005463 update to check if PC meets the system requirements of Windows 11
This application is installed with the KB5005463 update to Check whether PC meets the system requirements of Windows 11
Удалить приложение "Проверка работоспособности ПК Windows" и заблокировать его установку в будущем
Данное приложение устанавливается обновлением KB5005463 для проверки соответствия компьютера системным требованиям Windows 11

2
src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1

@ -12,7 +12,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

218
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -88,7 +88,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
# Check whether Microsoft Edge as being a system component was removed by harmful tweakers
if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
@ -177,17 +177,6 @@ public static string GetString(uint strId)
}
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -293,7 +282,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -304,42 +293,33 @@ public static string GetString(uint strId)
exit
}
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Warning -Message $Localization.Bin
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
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)
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
Write-Warning -Message $Localization.RebootPending
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -347,7 +327,7 @@ public static string GetString(uint strId)
exit
}
# Check if Microsoft Store being an important system component was removed
# Check whether Microsoft Store being an important system component was removed
if (-not (Get-AppxPackage -Name Microsoft.WindowsStore))
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store")
@ -358,55 +338,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -555,7 +486,88 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# 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
{
# 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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
{$_ -lt 22631}
@ -586,7 +598,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 2861)
{
# Check whether the OS minor build version is 2861 minimum
# Check whether Windows minor build version is 2861 minimum
# https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information#windows-11-current-versions
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -719,7 +731,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -4504,7 +4516,7 @@ function OneDrive
return
}
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -7749,7 +7761,7 @@ function WinPrtScrFolder
$Default
)
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -7831,7 +7843,7 @@ function WinPrtScrFolder
RecommendedTroubleshooting -Default
.NOTES
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
.NOTES
Machine-wide
@ -7875,7 +7887,7 @@ function RecommendedTroubleshooting
}
}
# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
# Set Windows level of diagnostic data gathering to "Optional diagnostic data"
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
@ -9920,7 +9932,7 @@ function Install-WSA
return
}
# Check if Windows 11 is installed on an SSD
# Check whether Windows 11 is installed on an SSD
$DiskNumber = (Get-Disk | Where-Object -FilterScript {$_.Isboot -and $_.IsSystem -and ($_.OperationalStatus -eq "Online")}).Number
if (Get-PhysicalDisk -DeviceNumber $DiskNumber | Where-Object -FilterScript {$_.MediaType -ne "SSD"})
{
@ -11745,7 +11757,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -12170,7 +12182,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -12474,7 +12486,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -14444,11 +14456,11 @@ function OpenWindowsTerminalAdminContext
if
(
# Check if it is not blocked by policy
# 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 if the package installed
# Check whether the package installed
(Get-AppxPackage -Name Microsoft.WindowsTerminal) -and
# Check if Windows Terminal version is greater or equal than 1.11
# 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")
)
{
@ -14605,7 +14617,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -14663,7 +14675,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -14823,7 +14835,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

4
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -790,7 +790,7 @@ WinPrtScrFolder -Desktop
<#
Run troubleshooter automatically, then notify me
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
Автоматически запускать средства устранения неполадок, а затем уведомлять
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -799,7 +799,7 @@ RecommendedTroubleshooting -Automatically
<#
Ask me before running troubleshooter (default value)
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data"
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data"
Спрашивать перед запуском средств устранения неполадок (значение по умолчанию)
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows

2
src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1

@ -12,7 +12,7 @@ RebootPending = The PC is waiting to be restarted.
UnsupportedRelease = A new version found.
KeyboardArrows = Please use the arrow keys {0} and {1} on your keyboard to select your answer
CustomizationWarning = Have you customized every function in the {0} preset file before running Sophia Script?
WindowsComponentBroken = {0} broken or removed from the OS.
WindowsComponentBroken = {0} broken or removed from Windows.
UpdateDefender = Microsoft Defender definitions are out-of-date. Run Windows Update and try again.
ControlledFolderAccessDisabled = Controlled folder access disabled.
InitialActionsCheckFailed = "InitialActions" function cannot be loaded from the {0} preset file.

228
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -84,7 +84,7 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
# Check whether Microsoft Edge as being a system component was removed by harmful tweakers
if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"))
{
Write-Information -MessageData "" -InformationAction Continue
@ -173,17 +173,6 @@ public static string GetString(uint strId)
}
}
# Check if Get-WindowsEdition cmdlet is working
try
{
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check the language mode
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
@ -289,7 +278,7 @@ public static string GetString(uint strId)
}
}
# Flibustier custom Windows image
# Check whether this is a Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
@ -300,47 +289,33 @@ public static string GetString(uint strId)
exit
}
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
# Check whether Get-WindowsEdition cmdlet is working
try
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
[void](Get-WindowsEdition -Online)
}
catch [System.Runtime.InteropServices.COMException]
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition")
exit
}
# Check whether all necessary files exist in the bin folder
$Files = @(
"$PSScriptRoot\..\bin\LGPO.exe",
"$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll",
"$PSScriptRoot\..\bin\WinRT.Runtime.dll"
)
if (($Files | Test-Path) -contains $false)
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
Write-Warning -Message $Localization.Bin
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack")
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
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)
# Check whether EventLog service is running in order to be sire that Event Logger is enabled
if ((Get-Service -Name EventLog).Status -eq "Stopped")
{
Write-Warning -Message $Localization.RebootPending
# Extract the localized "Event Viewer" string from shell32.dll
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -348,7 +323,7 @@ public static string GetString(uint strId)
exit
}
# Check if Microsoft Store being an important system component was removed
# Check whether Microsoft Store being an important system component was removed
if (-not (Get-AppxPackage -Name Microsoft.WindowsStore))
{
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store")
@ -359,55 +334,6 @@ public static string GetString(uint strId)
exit
}
# Check if the current module version is the latest one
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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
#region Defender checks
# Check whether necessary Microsoft Defender components exists
$Files = @(
@ -556,7 +482,93 @@ public static string GetString(uint strId)
}
#endregion Defender checks
# Detect the OS build version
# 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
{
# 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")
{
return
}
try
{
# https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json"
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
# Check whether all necessary files exist in the bin folder
$Files = @(
"$PSScriptRoot\..\bin\LGPO.exe",
"$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll",
"$PSScriptRoot\..\bin\WinRT.Runtime.dll"
)
if (($Files | Test-Path) -contains $false)
{
Write-Warning -Message $Localization.Bin
Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest"
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
{$_ -lt 22631}
@ -587,7 +599,7 @@ public static string GetString(uint strId)
{
if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 2861)
{
# Check whether the OS minor build version is 2861 minimum
# Check whether Windows minor build version is 2861 minimum
# https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information#windows-11-current-versions
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR
@ -720,7 +732,7 @@ public static string GetString(uint strId)
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
# Check if hosts contains any of string from $IPArray array
# Check whether hosts contains any of string from $IPArray array
if ((Get-Content -Path "$env:SystemRoot\System32\drivers\etc\hosts" -Encoding Default -Force | ForEach-Object -Process {$_.Trim()} | ForEach-Object -Process {
($_ -ne "") -and ($_ -ne " ") -and (-not $_.StartsWith("#")) -and ($IPArray -split "`r?`n" | Select-String -Pattern $_)
}) -contains $true)
@ -4505,7 +4517,7 @@ function OneDrive
return
}
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -7750,7 +7762,7 @@ function WinPrtScrFolder
$Default
)
# Check if user is logged into OneDrive (Microsoft account)
# Check whether user is logged into OneDrive (Microsoft account)
$UserEmail = Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name UserEmail -ErrorAction Ignore
if ($UserEmail)
{
@ -7832,7 +7844,7 @@ function WinPrtScrFolder
RecommendedTroubleshooting -Default
.NOTES
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data" and the error reporting feature will be turned on
.NOTES
Machine-wide
@ -7876,7 +7888,7 @@ function RecommendedTroubleshooting
}
}
# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
# Set Windows level of diagnostic data gathering to "Optional diagnostic data"
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
@ -9921,7 +9933,7 @@ function Install-WSA
return
}
# Check if Windows 11 is installed on an SSD
# Check whether Windows 11 is installed on an SSD
$DiskNumber = (Get-Disk | Where-Object -FilterScript {$_.Isboot -and $_.IsSystem -and ($_.OperationalStatus -eq "Online")}).Number
if (Get-PhysicalDisk -DeviceNumber $DiskNumber | Where-Object -FilterScript {$_.MediaType -ne "SSD"})
{
@ -11766,7 +11778,7 @@ function CleanupTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
{
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to check if the task was created
# Also we can parse "$env:SystemRoot\System32\Tasks\Sophia\Windows Cleanup" to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Windows Cleanup"} | Foreach-Object {
@ -12191,7 +12203,7 @@ function SoftwareDistributionTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "SoftwareDistribution"} | Foreach-Object {
@ -12495,7 +12507,7 @@ function TempTask
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to Check whether the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
$ScheduleService.Connect()
$ScheduleService.GetFolder("\Sophia").GetTasks(0) | Where-Object -FilterScript {$_.Name -eq "Temp"} | Foreach-Object {
@ -14465,11 +14477,11 @@ function OpenWindowsTerminalAdminContext
if
(
# Check if it is not blocked by policy
# 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 if the package installed
# Check whether the package installed
(Get-AppxPackage -Name Microsoft.WindowsTerminal) -and
# Check if Windows Terminal version is greater or equal than 1.11
# 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")
)
{
@ -14626,7 +14638,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -14684,7 +14696,7 @@ function UpdateLGPEPolicies
{
foreach ($Item in $Path.Property)
{
# Check if property isn't equal to "(default)" and exists
# Check whether property isn't equal to "(default)" and exists
if (($null -ne $Item) -and ($Item -ne "(default)"))
{
# Where all ADMX templates are located to compare with
@ -14844,7 +14856,7 @@ public static void PostMessage()
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its' argument

4
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -799,7 +799,7 @@ WinPrtScrFolder -Desktop
<#
Run troubleshooter automatically, then notify me
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data", and the error reporting feature will be turned on
Автоматически запускать средства устранения неполадок, а затем уведомлять
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows
@ -808,7 +808,7 @@ RecommendedTroubleshooting -Automatically
<#
Ask me before running troubleshooter (default value)
In order this feature to work the OS level of diagnostic data gathering will be set to "Optional diagnostic data"
In order this feature to work Windows level of diagnostic data gathering will be set to "Optional diagnostic data"
Спрашивать перед запуском средств устранения неполадок (значение по умолчанию)
Чтобы заработала данная функция, уровень сбора диагностических данных ОС будет установлен на "Необязательные диагностические данные" и включится создание отчетов об ошибках Windows

Loading…
Cancel
Save