PoshCode Archive  Artifact [4a03da5ae0]

Artifact 4a03da5ae0a3de160219277df9679a255f1891202764fe5c37c0f11e1236f3ae:

  • File WMI-wifi-metric-gt-LAN.ps1 — part of check-in [0a7a369a06] at 2018-06-10 14:01:32 on branch trunk — ConfigMgr CI remediation Sets WMI IPConnectionMetric of laptop Wi-Fi adapter to 100 + IPConnectionMetric of the LAN adaptor. based of Richard Siddaway’s work from powershell.com forum. (user: brockie size: 1506)

# encoding: ascii
# api: powershell
# title: WMI wifi metric > LAN 
# description: ConfigMgr CI remediation Sets WMI IPConnectionMetric of laptop Wi-Fi adapter to 100 + IPConnectionMetric of the LAN adaptor. based of Richard Siddaway’s work from powershell.com forum.
# version: 802.3
# type: function
# author: brockie
# license: CC0
# function: set-ipmetricWLAN
# x-poshcode-id: 5796
# x-archived: 2016-03-06T06:16:53
# x-published: 2016-03-26T18:27:00
#
#
function set-ipmetricWLAN {

param ( [uint32]$metric ) 

      $LAN = 
      Get-WmiObject Win32_NetworkAdapter -Filter "AdapterType='Ethernet 802.3'" |
      Where-Object { ($_.NetConnectionID -notlike '*Wireless*' -or $_.NetConnectionID -notlike '*WiFi*' -or $_.NetConnectionID -notlike '*Wi-Fi*' ) -and $_.ServiceName -notlike '*NETw*' } |
      ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') } | Where-Object {$_.IPEnabled -eq '$True'}

      $WLAN = 
      Get-WmiObject Win32_NetworkAdapter -Filter "AdapterType='Ethernet 802.3'" |
      Where-Object { ($_.NetConnectionID -like '*Wireless*' -or $_.NetConnectionID -like '*WiFi*' -or $_.NetConnectionID -like '*Wi-Fi*' -or $_.ServiceName -like '*NETw*') } |
      ForEach-Object { $_.GetRelated('Win32_NetworkAdapterConfiguration') } | Where-Object {$_.IPEnabled -eq '$True'}
      
   
$WLAN | Invoke-WmiMethod -Name SetIPConnectionMetric -ArgumentList ($LAN.IPConnectionMetric + $metric)

      
}

set-ipmetricWLAN -metric 100