Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an iis website that has been coded in asp and each piece of code is linked to an IP address. There are multiple servers in the setup so they all need doing. Literally thousands of files.

I’ve inherited a right mess!

Is there a powershell script something that could search for any bit of code that has “192.168.1.200” and change it to a dns record?

Yes I know it was ip’d on this range too!

The bindings etc and certs I’m fine with.

Nightmare and help appreciated!

What I have tried:

The ip of the servers were changed and it broke everything until they were reverted back.
Posted
Updated 19-Feb-21 22:44pm

1 solution

Something like:
PowerShell
Get-ChildItem -Path "FILETYPE" -Recurse | ForEach { (Get-Content -Path $_ | ForEach { $_ -replace "192.168.1.200", "DNSREF"}) | Set-Content $_ }

FILETYPE should be of the form "*.xxx", where xxx is the file extension of the files that need changing.
DNSREF should be the replacement string.

Create a test area with just a few files and try it out first to make sure it does not do any damage.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900