Network Query

Question

Hi Team,

I have got an request from customer to set the network preference first to LAN and then to Wifi using Powershell Script.

Currently now laptops are getting connected to wifi by default even though they are connected to LAN via direct wired connection or via docking station port.

What we want is: when ever laptop is connected to wired lan, it should get connected to LAN and when not connected to LAN it should get connected to wifi.

We are working on to achieve this through powershell script, if any help or suggestion on this would be very helpful.

Thanks,

solved 0
Vijay A 2 months 4 Answers 72 views Beginner 0

Answers ( 4 )

  1. I think so …test test test before using it in production

  2. Thanks Anoop for sharing the link.
    I will check this script and update you.
    Hope I can use the script ( Network_Metric.ps1 ) given in the link just download and upload ?

    Thanks Again 🙂

  3. Try this below one from Gallery

    https://gallery.technet.microsoft.com/scriptcenter/Change-wired-network-db174767

    Get-WmiObject -Class Win32_NetworkAdapter -Filter “AdapterType like ‘%802.3′” |
    %{
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter “Index=$($_.DeviceId)” | Select-Object Description,IPConnectionMetric
    }
    $INTERFACES=wmic nic get NetConnectionID

    $INTERFACES|%{
    if ($_ -like ‘區域連線*’ -or $_ -like ‘Local Area Connection*’)
    {
    $N=$_.trim()
    $ExParm=’netsh interface ip set interface interface=”‘+”$N”+'” metric =10’
    Write-Host $ExParm
    Invoke-Expression $ExParm
    }
    elseif ($_ -match ‘無線網路連線*’ -or $_ -like ‘Wireless Network Connection*’)
    {
    $N=$_.trim()
    $ExParm=’netsh interface ip set interface interface=”‘+”$N”+'” metric =50’
    Write-Host $ExParm
    Invoke-Expression $ExParm
    }
    }

    Write-Host ‘ ‘
    Write-Host —————————- New Connection Metic —————————-
    Write-Host ‘ ‘

    Get-WmiObject -Class Win32_NetworkAdapter -Filter “AdapterType like ‘%802.3′” |
    %{
    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter “Index=$($_.DeviceId)” | Select-Object Description,IPConnectionMetric
    }

    Best answer

Leave an answer

Sorry, you do not have a permission to answer to this question .