diff --git a/Wrapper/SophiaScriptWrapper.exe b/Wrapper/SophiaScriptWrapper.exe index fc8fc412..17086bcd 100644 Binary files a/Wrapper/SophiaScriptWrapper.exe and b/Wrapper/SophiaScriptWrapper.exe differ diff --git a/sophia_script_versions.json b/sophia_script_versions.json index a62b8c03..ce841a09 100644 --- a/sophia_script_versions.json +++ b/sophia_script_versions.json @@ -5,5 +5,5 @@ "Sophia_Script_Windows_10_LTSC2021": "5.18.7", "Sophia_Script_Windows_11_PowerShell_5_1": "6.6.7", "Sophia_Script_Windows_11_PowerShell_7": "6.6.7", - "Sophia_Script_Wrapper": "2.7.0" + "Sophia_Script_Wrapper": "2.7.1" } diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 97ce3d78..351f9150 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -159,7 +159,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 @@ -175,7 +177,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 @@ -186,7 +190,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether the script was run via PowerShell 5.1 if ($PSVersionTable.PSVersion.Major -ne 5) { + 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 @@ -197,7 +203,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 @@ -248,7 +256,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 @@ -258,7 +268,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 @@ -278,7 +290,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 @@ -288,20 +302,26 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Check whether Get-WindowsEdition cmdlet is working + # https://github.com/PowerShell/PowerShell/issues/21295 try { Get-WindowsEdition -Online } 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 @@ -312,8 +332,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 @@ -324,7 +346,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 @@ -343,7 +367,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 @@ -356,7 +382,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 @@ -372,8 +400,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 @@ -384,7 +414,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 @@ -400,7 +432,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 @@ -505,7 +539,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 @@ -541,7 +577,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 @@ -565,7 +603,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether LGPO.exe exists in the bin folder if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe")) { + 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 @@ -579,7 +619,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 @@ -647,7 +689,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 @@ -1173,6 +1217,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 @@ -11559,8 +11604,8 @@ function UninstallUWPApps # Outlook "Microsoft.OutlookForWindows", - # Chat (Microsoft Teams) - "MicrosoftTeams", + # Microsoft Teams + "MSTeams", # Microsoft Copilot "Microsoft.Windows.Ai.CoPilot.Provider" @@ -12826,7 +12871,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 = @{ @@ -12892,7 +12937,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 = @{ @@ -13213,7 +13258,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 = @{ @@ -13523,7 +13568,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 = @{ @@ -15409,12 +15454,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")) { diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index a9d0c025..9bd17883 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -159,7 +159,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 @@ -175,7 +177,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 @@ -186,7 +190,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether the script was run via PowerShell 5.1 if ($PSVersionTable.PSVersion.Major -ne 5) { + 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 @@ -197,7 +203,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 @@ -246,7 +254,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 @@ -256,7 +266,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 @@ -276,7 +288,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 @@ -286,21 +300,28 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Check whether Get-WindowsEdition cmdlet is working + # https://github.com/PowerShell/PowerShell/issues/21295 try { Get-WindowsEdition -Online } 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 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-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -319,7 +340,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 @@ -332,7 +355,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 @@ -348,8 +373,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 @@ -360,7 +387,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 @@ -376,7 +405,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 @@ -469,7 +500,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 @@ -505,7 +538,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 @@ -529,7 +564,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether LGPO.exe exists in the bin folder if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe")) { + 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 @@ -554,7 +591,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { {$_ -ne 17763} { + 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 @@ -619,7 +658,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # https://support.microsoft.com/en-us/topic/windows-10-and-windows-server-2019-update-history-725fc2e1-4443-6831-a5ca-51ff5cbcb059 $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 @@ -1139,6 +1180,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 @@ -9364,7 +9406,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 = @{ @@ -9430,7 +9472,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 = @{ @@ -9751,7 +9793,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 = @{ @@ -10061,7 +10103,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 = @{ @@ -11880,12 +11922,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")) { diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index ba69a2e0..a6b3a6b4 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -159,7 +159,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 @@ -175,7 +177,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 @@ -186,7 +190,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether the script was run via PowerShell 5.1 if ($PSVersionTable.PSVersion.Major -ne 5) { + 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 @@ -197,7 +203,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 @@ -246,7 +254,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 @@ -256,7 +266,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 @@ -276,7 +288,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 @@ -286,21 +300,28 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Check whether Get-WindowsEdition cmdlet is working + # https://github.com/PowerShell/PowerShell/issues/21295 try { Get-WindowsEdition -Online } 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 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-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose @@ -319,7 +340,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 @@ -332,7 +355,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 @@ -348,8 +373,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 @@ -360,7 +387,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 @@ -376,7 +405,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 @@ -469,7 +500,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 @@ -505,7 +538,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 @@ -529,7 +564,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether LGPO.exe exists in the bin folder if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe")) { + 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 @@ -554,7 +591,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { {$_ -ne 19044} { + 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 @@ -619,7 +658,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # https://support.microsoft.com/en-us/topic/windows-10-update-history-857b8ccb-71e4-49e5-b3f6-7073197d98fb $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 @@ -1139,6 +1180,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 @@ -10499,7 +10541,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 = @{ @@ -10565,7 +10607,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 = @{ @@ -10886,7 +10928,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 = @{ @@ -11196,7 +11238,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 = @{ @@ -13075,12 +13117,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")) { diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index cb34959b..db01342a 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -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")) { diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index a6b9977a..0bd983f5 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -147,7 +147,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 @@ -163,7 +165,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 @@ -174,7 +178,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether the script was run via PowerShell 5.1 if ($PSVersionTable.PSVersion.Major -ne 5) { + 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 @@ -185,7 +191,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 @@ -236,7 +244,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 @@ -246,7 +256,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 @@ -266,7 +278,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 @@ -276,20 +290,26 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); } # Check whether Get-WindowsEdition cmdlet is working + # https://github.com/PowerShell/PowerShell/issues/21295 try { Get-WindowsEdition -Online } 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 @@ -300,8 +320,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 @@ -312,7 +334,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 @@ -331,7 +355,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 @@ -344,7 +370,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 @@ -360,8 +388,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 @@ -372,7 +402,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 @@ -388,7 +420,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 @@ -481,7 +515,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 @@ -517,7 +553,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 @@ -541,7 +579,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Check whether LGPO.exe exists in the bin folder if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe")) { + 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 @@ -555,7 +595,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { {$_ -lt 22631} { + 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 @@ -623,7 +665,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # https://support.microsoft.com/en-us/topic/windows-11-version-23h2-update-history-59875222-b990-4bd9-932f-91a5954de434 $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 @@ -1149,6 +1193,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 @@ -10895,8 +10940,8 @@ function UninstallUWPApps # Outlook "Microsoft.OutlookForWindows", - # Chat (Microsoft Teams) - "MicrosoftTeams", + # Microsoft Teams + "MSTeams", # Microsoft Copilot "Microsoft.Windows.Ai.CoPilot.Provider" @@ -11995,7 +12040,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 = @{ @@ -12061,7 +12106,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 = @{ @@ -12382,7 +12427,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 = @{ @@ -12692,7 +12737,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 = @{ diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index f457a747..5de20ec0 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -146,7 +146,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 @@ -162,7 +164,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 @@ -173,7 +177,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 @@ -184,7 +190,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 @@ -235,7 +243,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 @@ -245,7 +255,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 @@ -265,7 +277,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 @@ -275,6 +289,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 @@ -283,14 +298,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 @@ -301,8 +321,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 @@ -313,7 +335,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 @@ -332,7 +356,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 @@ -345,7 +371,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 @@ -361,8 +389,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 @@ -373,7 +403,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 @@ -389,7 +421,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 @@ -482,7 +516,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 @@ -518,7 +554,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 @@ -547,7 +585,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 @@ -561,7 +601,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); { {$_ -lt 22631} { + 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 @@ -629,7 +671,9 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # https://support.microsoft.com/en-us/topic/windows-11-version-23h2-update-history-59875222-b990-4bd9-932f-91a5954de434 $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 @@ -1155,6 +1199,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 @@ -10911,8 +10956,8 @@ function UninstallUWPApps # Outlook "Microsoft.OutlookForWindows", - # Chat (Microsoft Teams) - "MicrosoftTeams", + # Microsoft Teams + "MSTeams", # Microsoft Copilot "Microsoft.Windows.Ai.CoPilot.Provider" @@ -12021,7 +12066,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 = @{ @@ -12087,7 +12132,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 = @{ @@ -12408,7 +12453,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 = @{ @@ -12718,7 +12763,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 = @{