Solved

Script To : Change Subnet Mask on 200 + W2003 Servers

Posted on 2012-03-23
7
173 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
[X]
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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
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 …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

752 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