From 0b7300c6cbbf69a5ac3d9852aa2c7924f98c8c1b Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sun, 27 Oct 2024 19:20:42 +0300 Subject: [PATCH] Improved errors readability and `NetworkAdaptersSavePower` function --- src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 | 2 +- src/Sophia_Script_for_Windows_10/Sophia.ps1 | 2 +- src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 | 2 +- src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 | 2 +- src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 | 2 +- src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 | 2 +- .../Module/Sophia.psm1 | 4 ++-- src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 | 2 +- src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 | 2 +- src/Sophia_Script_for_Windows_11/Sophia.ps1 | 2 +- src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 | 2 +- src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 | 2 +- .../Module/Sophia.psm1 | 4 ++-- src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 94ce6f7e8..8ddd30410 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -308,7 +308,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index b5645a29e..58ce48fc4 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1 @@ -91,7 +91,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose 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 635f2daeb..43014b633 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 @@ -306,7 +306,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 index f78eafb8e..2361881a7 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 @@ -89,7 +89,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose 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 db03b5440..98b601411 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 @@ -306,7 +306,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 index c8e275609..65eeb6a1a 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 @@ -89,7 +89,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose 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 fd4f931e2..683148f7a 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 @@ -307,7 +307,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll @@ -690,7 +690,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue } - # Check whether all necessary files exist in the bin folder + # Check whether all necessary files exist in the script folder $Files = @( "$PSScriptRoot\..\bin\LGPO.exe", "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll", diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 index b2b54bd2a..9b2e25327 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 @@ -91,7 +91,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 580d9179f..935e01fac 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -294,7 +294,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index 1a4c48560..431eeab6a 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1 @@ -90,7 +90,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 index 15e13ed3a..078afbcd7 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 @@ -292,7 +292,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 index 887a3dba9..670973034 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 @@ -88,7 +88,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose 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 bd77d9365..2a81225d3 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 @@ -293,7 +293,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); # Remove firewalled IP addresses that block Microsoft recourses added by harmful tweakers # https://wpd.app - Get-NetFirewallRule | Where-Object -FilterScript {($_.DisplayName -match "Blocker MicrosoftTelemetry") -or ($_.DisplayName -match "Blocker MicrosoftExtra") -or ($_.DisplayName -match "windowsSpyBlocker")} | Remove-NetFirewallRule + Get-NetFirewallRule -DisplayName "Blocker MicrosoftTelemetry*", "Blocker MicrosoftExtra*", "windowsSpyBlocker*" -ErrorAction Ignore | Remove-NetFirewallRule Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll @@ -664,7 +664,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue } - # Check whether all necessary files exist in the bin folder + # Check whether all necessary files exist in the script folder $Files = @( "$PSScriptRoot\..\bin\LGPO.exe", "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll", diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 index 42a5e0d62..2e9088aca 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 @@ -90,7 +90,7 @@ $ScriptFiles = @( if (($ScriptFiles | Test-Path) -contains $false) { Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message "There are no files in the bin folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." + Write-Warning -Message "There are no files in the script folder. Please, re-download the archive and follow the guide: https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-use." Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://t.me/sophia_chat" -Verbose