Backitup01
MIS
- Jan 22, 2009
- 1
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,
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,