Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Script To : Change Subnet Mask on 200 + W2003 Servers

Posted on 2012-03-23
7
167 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

860 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