|
|
@ -158,7 +158,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Check the language mode |
|
|
|
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.UnsupportedLanguageMode |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes" -Verbose |
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
@ -174,7 +176,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
|
|
|
|
if ($CurrentUserName -ne $LoginUserName) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.LoggedInUserNotAdmin |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -185,7 +189,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Check whether the script was run via PowerShell 7 |
|
|
|
if ($PSVersionTable.PSVersion.Major -ne 7) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.UnsupportedPowerShell -f $PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -196,7 +202,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Check whether the script was run in PowerShell ISE or VS Code |
|
|
|
if (($Host.Name -match "ISE") -or ($env:TERM_PROGRAM -eq "vscode")) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.UnsupportedHost -f $Host.Name.Replace("Host", "")) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -247,7 +255,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
{ |
|
|
|
if ($Tweakers[$Tweaker] -eq "HKCU:\Software\Win 10 Tweaker") |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.Win10TweakerWarning |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://youtu.be/na93MS-1EkM" -Verbose |
|
|
|
Write-Verbose -Message "https://pikabu.ru/story/byekdor_v_win_10_tweaker_ili_sovremennyie_metodyi_borbyi_s_piratstvom_8227558" -Verbose |
|
|
@ -257,7 +267,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
exit |
|
|
|
} |
|
|
|
|
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -277,7 +289,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
{ |
|
|
|
if ($Tweakers[$Tweaker]) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.TweakerWarning -f $Tweaker) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -287,6 +301,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
} |
|
|
|
|
|
|
|
# Check whether Get-WindowsEdition cmdlet is working |
|
|
|
# https://github.com/PowerShell/PowerShell/issues/21295 |
|
|
|
try |
|
|
|
{ |
|
|
|
# Import PowerShell 5.1 DISM module |
|
|
@ -295,14 +310,19 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
} |
|
|
|
catch [System.Runtime.InteropServices.COMException] |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Get-WindowsEdition") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
exit |
|
|
|
} |
|
|
|
|
|
|
|
# Check whether Windows Feature Experience Pack was removed by harmful tweakers |
|
|
|
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS)) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Windows Feature Experience Pack") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -313,8 +333,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# 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-Information -MessageData "" -InformationAction Continue |
|
|
|
# Extract the localized "Event Viewer" string from shell32.dll |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStrings]::GetString(22029))) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -325,7 +347,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Check whether Microsoft Store being an important system component was removed |
|
|
|
if (-not (Get-AppxPackage -Name Microsoft.WindowsStore)) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Store") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -344,7 +368,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
{ |
|
|
|
if (-not (Test-Path -Path $File)) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f $File) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose |
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
@ -357,7 +383,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Checking whether Windows Security Settings page was hidden from UI |
|
|
|
if ([Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", "SettingsPageVisibility", $null) -match "hide:windowsdefender") |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -373,8 +401,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
catch [Microsoft.Management.Infrastructure.CimException] |
|
|
|
{ |
|
|
|
# Provider Load Failure exception |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Global:Error.Exception.Message | Select-Object -First 1 |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -385,7 +415,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# Check Microsoft Defender state |
|
|
|
if ($null -eq (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction Ignore)) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -401,7 +433,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
} |
|
|
|
catch [Microsoft.PowerShell.Commands.ServiceCommandException] |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Defender") |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -506,7 +540,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
) |
|
|
|
if (($PendingActions | Test-Path) -contains $true) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.RebootPending |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -542,7 +578,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
|
|
|
|
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.UnsupportedRelease |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose |
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
@ -571,7 +609,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
) |
|
|
|
if (($Files | Test-Path) -contains $false) |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.Bin |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" -Verbose |
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
@ -585,7 +625,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
{ |
|
|
|
{$_ -ne 19045} |
|
|
|
{ |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message $Localization.UnsupportedOSBuild |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -653,7 +695,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); |
|
|
|
# https://support.microsoft.com/en-us/topic/windows-10-update-history-8127c2c6-6edf-4fdf-8b9f-0f7be1ef3562 |
|
|
|
$CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild |
|
|
|
$UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Warning -Message ($Localization.UpdateWarning -f $CurrentBuild.CurrentBuild, $UBR.UBR, $LatestSupportedBuild) |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -1179,6 +1223,7 @@ function DiagTrackService |
|
|
|
$PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
Write-Verbose -Message ($Localization.InitialActionsCheckFailed -f $PresetName) -Verbose |
|
|
|
Write-Information -MessageData "" -InformationAction Continue |
|
|
|
|
|
|
|
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose |
|
|
|
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose |
|
|
@ -11575,8 +11620,8 @@ function UninstallUWPApps |
|
|
|
# Outlook |
|
|
|
"Microsoft.OutlookForWindows", |
|
|
|
|
|
|
|
# Chat (Microsoft Teams) |
|
|
|
"MicrosoftTeams", |
|
|
|
# Microsoft Teams |
|
|
|
"MSTeams", |
|
|
|
|
|
|
|
# Microsoft Copilot |
|
|
|
"Microsoft.Windows.Ai.CoPilot.Provider" |
|
|
@ -12852,7 +12897,7 @@ while (`$true) |
|
|
|
[int]`$CurrentMainWindowHandle = (Get-Process -Name cleanmgr | Where-Object -FilterScript {`$_.PriorityClass -eq """BelowNormal"""}).MainWindowHandle |
|
|
|
if (`$SourceMainWindowHandle -ne `$CurrentMainWindowHandle) |
|
|
|
{ |
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll") |
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("""System.dll""") |
|
|
|
`$CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new(`$env:TEMP, `$false) |
|
|
|
`$CompilerParameters.GenerateInMemory = `$true |
|
|
|
`$Signature = @{ |
|
|
@ -12918,7 +12963,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); |
|
|
|
# https://github.com/DCourtel/Windows_10_Focus_Assist/blob/master/FocusAssistLibrary/FocusAssistLib.cs |
|
|
|
# https://redplait.blogspot.com/2018/07/wnf-ids-from-perfntcdll-adk-version.html |
|
|
|
|
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll") |
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("""System.dll""") |
|
|
|
`$CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new(`$env:TEMP, `$false) |
|
|
|
`$CompilerParameters.GenerateInMemory = `$true |
|
|
|
`$Signature = @{ |
|
|
@ -13239,7 +13284,7 @@ function SoftwareDistributionTask |
|
|
|
# https://github.com/DCourtel/Windows_10_Focus_Assist/blob/master/FocusAssistLibrary/FocusAssistLib.cs |
|
|
|
# https://redplait.blogspot.com/2018/07/wnf-ids-from-perfntcdll-adk-version.html |
|
|
|
|
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll") |
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("""System.dll""") |
|
|
|
`$CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new(`$env:TEMP, `$false) |
|
|
|
`$CompilerParameters.GenerateInMemory = `$true |
|
|
|
`$Signature = @{ |
|
|
@ -13549,7 +13594,7 @@ function TempTask |
|
|
|
# https://github.com/DCourtel/Windows_10_Focus_Assist/blob/master/FocusAssistLibrary/FocusAssistLib.cs |
|
|
|
# https://redplait.blogspot.com/2018/07/wnf-ids-from-perfntcdll-adk-version.html |
|
|
|
|
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll") |
|
|
|
`$CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("""System.dll""") |
|
|
|
`$CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new(`$env:TEMP, `$false) |
|
|
|
`$CompilerParameters.GenerateInMemory = `$true |
|
|
|
`$Signature = @{ |
|
|
@ -15435,12 +15480,6 @@ public static void PostMessage() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($Script:RegionChanged) |
|
|
|
{ |
|
|
|
# Set the original region ID |
|
|
|
Set-WinHomeLocation -GeoId $Script:Region |
|
|
|
} |
|
|
|
|
|
|
|
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its own database |
|
|
|
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt")) |
|
|
|
{ |
|
|
|