Browse Source

Improved NetworkAdaptersSavePower function

pull/437/head
Dmitry Nefedov 2 years ago
parent
commit
d33865c4c7
  1. 8
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 8
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 8
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 8
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 8
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 8
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

8
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -6252,12 +6252,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -6285,7 +6285,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

8
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -4957,12 +4957,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -4990,7 +4990,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

8
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -5344,12 +5344,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -5377,7 +5377,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

8
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -6260,12 +6260,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -6293,7 +6293,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

8
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -5723,12 +5723,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -5756,7 +5756,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

8
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -5731,12 +5731,12 @@ function NetworkAdaptersSavePower
$Enable
)
if (Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"})
if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).Name)
$PhysicalAdaptersStatusUp = @((Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}).Name)
}
$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
$Adapters = Get-NetAdapter -Physical | Where-Object -FilterScript {$_.MacAddress} | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
switch ($PSCmdlet.ParameterSetName)
{
@ -5764,7 +5764,7 @@ function NetworkAdaptersSavePower
{
while
(
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {$_.Status -eq "Disconnected"}
Get-NetAdapter -Physical -Name $PhysicalAdaptersStatusUp | Where-Object -FilterScript {($_.Status -eq "Disconnected") -and $_.MacAddress}
)
{
Write-Verbose -Message $Localization.Patient -Verbose

Loading…
Cancel
Save