Programmatically Setting Static IP’s in a Computer Lab

If your organization has computer labs which require static IP addresses, here is a very easy method to deploy static IP’s to each lab. Most labs will have some sort of numbering scheme as part of the computer name. We can take advantage of this in order to transform the computer number into an IP address.

In my example, the computer number is at the end of the computer name. I am going to use PowerShell to calculate the new IP address for each computer, apply the new network configuration, register the new settings, and output a log file. Here is the script:

In my example, I have a lab of computers named CO-ROOM-200-00, CO-ROOM-200-01, etc. The static IP’s I want to assign these computers are,, etc. So in my script I am taking that last 00 and 01 and adding 100 to it. Simple as that.

After that, we set the DNS servers. If you have more than one DNS server, you need to set them as an array, because the “SetDNSServerSearchOrder” property cannot accept two separate strings otherwise.

Finally, we update DNS and output a log file. This script can now be deployed using any method, such as SCCM, in order to set static IP addresses in bulk to an entire room of computers, if the computers are sequentially numbered.

And here is the script to undo these changes and to re-enable DHCP: How to enable DHCP using PowerShell.

1 thought on “Programmatically Setting Static IP’s in a Computer Lab”

  1. Pingback: How to enable DHCP using PowerShell |

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.