Solved

Script To : Change Subnet Mask on 200 + W2003 Servers

Posted on 2012-03-23
7
164 Views
Last Modified: 2014-07-26
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
Comment
Question by:dirtyg00se
  • 2
  • 2
7 Comments
 

Author Comment

by:dirtyg00se
ID: 37759583
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
 
LVL 29

Accepted Solution

by:
matrixnz earned 500 total points
ID: 37760379
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
 
LVL 77

Expert Comment

by:Rob Williams
ID: 37760446
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
 

Author Comment

by:dirtyg00se
ID: 37763958
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
 
LVL 29

Expert Comment

by:matrixnz
ID: 37764009
%ComputerName% should be unique enough, as you can't have two servers with the same name on the same network.

Cheers
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question