Search Text and replace it from a csv list

Hello everyone,

I’m new to powershell

I’m trying to figure out how to link a list of words (csv) to look for in several files and replace them with those in this same List.

basically I try to make it look in all files for the text OldNameServer1 and replace it with NewNameServer1
I think it’s doable but I don’t know how to attach the Foreach to my Select-String -replace.

I admit that I am lost.

My csv

Old, new
OldNameServer1, NewNameServer1
OldNameServer2, NewNameServer2

Thank you if you can refer me

@Africanism78 Welcome to PowerShell.org forums.

Below cmdlets will help you to do it. Reading those docs and looking at their example, it will be an easy task for you.

Import-Csv (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs
ForEach-Object (Microsoft.PowerShell.Core) - PowerShell | Microsoft Docs
Export-Csv (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs

Put up some code using above help and let folks here know if you face any error or difficulty.

1 Like