Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Script To : Change Subnet Mask on 200 + W2003 Servers

Pretty simple, we need to be able to do the following and need some sharp scritping folks help:

1. Change all 200+ servers from a /24 to /22 via script
2. Output a log file to a network share.

Any help greatly appreciated.

Thanks!
0
dirtyg00se
Asked:
dirtyg00se
  • 2
  • 2
1 Solution
 
dirtyg00seAuthor Commented:
Okay Soo....

The following works great in combination with PSEXEC. What I now want to do is for each system I run this on....write back to a log file as proof of successful change.

Anyone help me out ?

ipconfig /all >C:\ipc.txt
For /F "tokens=2 delims=:" %%A IN ('Find /I "IP Address" c:\ipc.txt') do set IP=%%A
netsh interface ip set address name = "Local Area Connection" source = static addr = %IP% mask = 255.255.252.0
del c:\ipc.txt

Exit

Again any help appreciateed.
0
 
matrixnzCommented:
Why not just pipe netsh command to a log file?  for example:
net use x: \\server\share
ipconfig /all >C:\ipc.txt
For /F "tokens=2 delims=:" %%A IN ('Find /I "IP Address" c:\ipc.txt') do set IP=%%A
netsh interface ip set address name = "Local Area Connection" source = static addr = %IP% mask = 255.255.252.0>x:\FileName.log
net use x: /delete
del c:\ipc.txt

Open in new window

0
 
Rob WilliamsCommented:
The catch with using either of the above is the network adapter name has to be exactly correct.  Though most often it is "Local Area Connection" if it is "Local Area Connection 2" or anything else those scripts will fail.
0
 
dirtyg00seAuthor Commented:
Agreed to both. I have not tried the example yet, but could you provide me with an example to write a unique logfile name for each system ?

Thank you for your help.

Brian
0
 
matrixnzCommented:
%ComputerName% should be unique enough, as you can't have two servers with the same name on the same network.

Cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now