Solved

Script To : Change Subnet Mask on 200 + W2003 Servers

Posted on 2012-03-23
7
159 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
%ComputerName% should be unique enough, as you can't have two servers with the same name on the same network.

Cheers
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now