Friday, March 24, 2017

Changing NIC Provider Order with Powershell Script

NIC Provider Order


Hello 2017! I hope everyone had a great 2016. My son was born in December 2016 and 2016 was the best year for me.

Now, I am back to my full time job. This is my first blog of 2017.

Here we go.....

Before configuring Availability Groups, we will need to configure NIC Provider Order and Binding Order. Usually, I changed them manually. If we are changing it in multiple servers, it will take time to configure them. So, I created a powershell script to change NIC provider order.

Manual Steps - Screenshots below are the steps how to change NIC provider order manually.


In Network and Sharing,
Click on Public NIC, press Alt + N , Click on Advanced Settings




Move Microsoft Windows Network on the top



The powershell script below is how to change Provider Order. I want to move Microsoft Windows Network on top of the rest.I am planning to use it in VM template deployment. Thank you for visiting my page.

$newproder = @()
$writereg = $null
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order'
$value = 'ProviderOrder'

#get values in registry
$proder = (Get-ItemProperty $key $value).$value | % {$_.split(",")}

#Order
if ($proder -contains "LanmanWorkstation") {$newproder += "LanmanWorkstation"}
if ($proder -contains "RDPNP") {$newproder += "RDPNP"}
if ($proder.count -gt $newproder.count) {$newproder += $proder}

$newproder = $newproder | select -unique

#Make a string
$newproder|ForEach-Object{$writereg += $_+","}

$writereg = $writereg.substring(0,$writereg.length-1)

#Change registry valules
Set-ItemProperty -path $key -Name $value -Value $writereg

I will reboot the server to take affect the changes. 

My reference is 

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/9a91540a-8c24-4f97-a433-70e4c9c7b709/change-network-providerorder-using-powershell?forum=ITCG

2 comments:

  1. Thanks! This helped me solve an issue with Novell Netware as a primary provider (port 524) causing a 20 second delay before connecting to a windows file services share (port 445).

    ReplyDelete
  2. Thanks for the script, I started to use it, but realized I could improve on it a bit:


    $KEY = 'HKLM:\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order'
    $VAL = 'ProviderOrder'
    $NPO = @()
    $OPO = (Get-ItemProperty $KEY $VAL).$VAL | % {$_.split(",")}
    $REG = $null
    if ($OPO -contains "LanmanWorkstation") {$NPO += "LanmanWorkstation"}
    $NPO = $NPO + $OPO | Select -Unique
    $REG = $NPO -join ","
    Set-ItemProperty -path $KEY -Name $VAL -Value $REG

    ReplyDelete

How to add a Database to AlwaysOn Availability Group with four different options

To add a database to an existing AlwaysOn availability group, MS has given us four options to choose from Automatic seeding Full database an...