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= mask= gateway=;netsh interface ip set dnsserver “LAN” static primary;netsh interface ip add dnsserver name=LAN index=2;netsh interface ip set winsserver “LAN” static;netsh interface ip add winsserver “LAN” 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: , , , ,

Comments are closed.

Copy Protected by Chetan's WP-Copyprotect.