Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Windows Script to Change IP and shutdown multiple computers

Windows Script to Change IP and shutdown multiple computers

Windows Script to Change IP and shutdown multiple computers

Let me start with the fact that I am an admin, not a scripting expert. We will be moving our datacenter and I need a way to quickly change IP info (to match the new site) and then shutdown the servers prior to moving so that (hopefully) when they power on, networking will be correct. Saving us hours of headache fighting with the KVM to get things online.

I have tried several things, but this is what I am thinking:

1. Script will be run from a technician's pc while on-site during the shutdown
2. list of computers to include name, new ip, new mask, new gateway will be passed into the script and enumerated as variables. (This part I can do locally, but not sure how to pass those vairables to the remote computer)
3. Script will include netsh commands to modify ip settings
4. Script will include a shutdown command to power off the computer after the ip information has been changed.

This is one of the trials that I was working on:

rem start shutdown process:
shutdown /s /m \\<servername> /t 1500

rem Read in the file (server names and IPs) and assign variables:
for /f "tokens=1-4 delims= " %%a in (c:\ipservers.txt) do (
netsh interface ipv4 delete interface "Local Area Connection"
netsh interface ipv4 delete address name="Local Area Connection"
netsh interface ipv4 delete dns name="Local Area Connection"
netsh interface ipv4 add address name="Local Area Connection" %%b %%c gateway=%%d
netsh interface ipv4 set dns name="Local Area Connection" static <dns_server1>
netsh interface ipv4 add dns name="Local Area Connection" <dns_server2> index=2

<end of script>

servers.txt would have this format:
<servername> <ipaddress> <mask> <gateway>

Any tips/pointers/examples would be greatly appreciated. I am sure someone has been through something similar.

Thanks in advance,

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close