page contents

About the Post

Author Information

HOW TO: Add Many NIC configuration settings with “NETSH”

I had a task recently that required me to spin up a new environment for testing. I had about 20 new virtual machines that I needed to deploy and they all had static entries. As you may or may not know, the SCVMM console does not allow you to copy and paste like you can with RDP or Remote Desktop connections. Hyper-V does allow you to “text” a paste but it can take a while, which means I had a problem. I did not want to waste my time typing out each and every NIC setting for all 20 machines. I needed to deploy this solution faster and really find a way to limit the typing.

I decided that I would use netsh and PowerShell to accomplish this task. I am only using PowerShell to allow me to add multiple lines and to be upfront, I am not actually using any PowerShell  commands. With that being said, lets see what I did to help limit this time being consumed.

So, here you can see that I have a NIC named the default “Local Area Connection”

I am going to rename it to LAN (as you would rename a NIC when you have multiple NICs so that you can easily identify it) I just right click on it and select rename:

Just for sanity I am going to show you that I do not have any settings configured for this NIC:

No DNS is set either:

No WINS is set as well:

I know, WINS is being deprecated, but I know some people that still rely on WINS for some older applications.

Now, I will launch PowerShell and enter in these NETSH commands:

netsh interface ipv4 set address name=LAN source=static address=192.168.1.23 mask=255.255.255.0 gateway=192.168.1.1;netsh interface ip set dnsserver “LAN” static 192.168.1.6 primary;netsh interface ip add dnsserver name=LAN 192.168.1.34 index=2;netsh interface ip set winsserver “LAN” static 192.168.10.55;netsh interface ip add winsserver “LAN” 192.168.10.56 index=2

Notice there are multiple entries with a “;” separate them so that they all get run at the same time. I use the “Type Clipboard Text”

Here is the command that I used to change my NIC settings:

Now lets check the NIC settings after we ran this command to see what happened.

Let’s check the WINS entries:

As you can see, we are golden. The nice thing about this method is that I only typed this command once (in Notepad) and just pasted one time without having to type much. 🙂

As usual, I hope this helps you and if you have any other questions, please look at the new NETSH commands.

Tags: , , , ,

Trackbacks/Pingbacks

  1. HOW TO: Add Many NIC configuration settings with PowerShell | Scott Mattie's Blog - May 15, 2012

    […] TO: Add Many NIC configuration settings with PowerShell In yesterday’s post, I talk about using PowerShell to configure many NIC’s with NETSH. Today, I am going to cover […]

  2. HOW TO: Add Many NIC configuration settings with PowerShell - SQL Server - SQL Server - Telligent - February 8, 2013

    […] yesterday’s post, I talk about using PowerShell to configure many NIC’s with NETSH. Today, I am going to cover […]

Copy Protected by Chetan's WP-Copyprotect.