Link to home
Start Free TrialLog in
Avatar of Jey_P
Jey_PFlag for Canada

asked on

Scripting

Hi Experts

I have a situation in my work need to change the IP address for few windows 2003 and 2008 servers in C:\Program Files\App\opt.txt( this text file has IP address and that need be change in different IP) . the application work with IP address.
I have a servers list in the CSV or TXT file, I am looking for the PowerShell scrip and that need to execute from workstation. Script goes and changes the IP address in opt.txt in the program file.
Please help me with this scripting … much appreciate.

Thanks

Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

As in you need to read the current IP of the system and put it into that text file?

Chris
Avatar of Jey_P

ASKER


thanks for your responce, no need to read the IP  and need to change the different IP .

There are one application server in our company and client installed every servers , the client will hold the application server IP in txt file located in C:\.  We are in situation to move the new VLAN and new IP. So instated of login each server and modify the IP, I am looking for the power shell command to modify the IP address number of servers in one shot. Is it possible to do it in PowerShell?  Sorry for the confusion.
Sure, it's not so hard. First, we get the right network interface. Does anything have more than one?

Then our code looks something like this:
$Network = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled=$True"
$Network.EnableStatic("New.IP.Address", "New.Subnet.Mask")
$Network.SetGateways("New.IP.Gateway")

Open in new window

Of course, it'll be a bit tricky doing this over the network, you'll lose connection the moment you change IP. But we can work with that if we make sure whatever script we run is running on the host machine, not over the network.

Will subnet mask and gateway be the same in all cases? And do you need to change any of the other details?

Chris
Avatar of Jey_P

ASKER

Thanks Chris.

we not going to change the host IP  . I want to replace the old IP to New IP that located in the C:\programfile\.txt .
Avatar of Jey_P

ASKER

Can you please modify the script bit and help me to complete this task. Only I need to change the IP for application that installed in the txt file located (c:\program files\app\txt.), I am not change the host IP.
I have numerous hosts have same above situation to change the IP. (the IP in CSV format).
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial