From d40e37f8e53505e06b426f80496b1bbb8aacb978 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 1 Feb 2025 23:26:40 +0300 Subject: [PATCH] Minor changes --- src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 | 4 +++- src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 | 4 +++- src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 | 4 +++- .../Module/Sophia.psm1 | 4 +++- src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 | 4 +++- src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 | 4 +++- .../Module/Sophia.psm1 | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 4b40b331..8f13a163 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -6720,7 +6720,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -15338,6 +15339,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions 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 2791666d..f1973c8d 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 @@ -5312,7 +5312,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -11794,6 +11795,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions 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 224e722b..756b7d60 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 @@ -5710,7 +5710,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -13159,6 +13160,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions 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 4750c099..b79f6451 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 @@ -6740,7 +6740,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -15368,6 +15369,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 87fe4878..9a984176 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -6438,7 +6438,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -14322,6 +14323,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions 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 d72ab4b1..fd9d8158 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 @@ -5966,7 +5966,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -13151,6 +13152,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions 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 7cfd07ba..23a8092d 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 @@ -6458,7 +6458,8 @@ function NetworkAdaptersSavePower Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Checking whether there's an adapter that has AllowComputerToTurnOffDevice property to manage - $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} + # We need also check for adapter status per some laptops have many equal adapters records in adapters list + $Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress -and ($_.Status -eq "Up")} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"} if (-not $Adapters) { Write-Information -MessageData "" -InformationAction Continue @@ -14352,6 +14353,7 @@ public static void PostMessage() Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose Write-Verbose -Message "https://ko-fi.com/Q5Q51QUJC" -Verbose Write-Verbose -Message "https://boosty.to/sophiascript" -Verbose + Write-Information -MessageData "" -InformationAction Continue } #endregion Post Actions