# encoding: ascii
# api: powershell
# title: WMI wifi metric &gt; 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
