I'm searching to replace 2 occurrences of a specific string but each by one data different.
Here the file with 2 lines :
[SERVER1]
NAME = SERVER1\SQLEXPRESS
ODBCLINK = idms
USER = idms
PSW = idms
[SERVER2]
NAME = SERVER2\SQLEXPRESS
ODBCLINK = backupidms
USER = idms
PSW = idms
For the moment I have that code:
Get-Content ".\test.ini") | ForEach-Object { $_ -replace ".+\SQLEXPRESS" , "Name = $hostname\SQLEXPRESS" } | Set-Content ".\test.ini"
The goal is to have that :
[SERVER1]
NAME = Paris\SQLEXPRESS
ODBCLINK = idms
USER = idms
PSW = idms
[SERVER2]
NAME = Nantes\SQLEXPRESS
ODBCLINK = backupidms
USER = idms
PSW = idms
I read these 2 strings, Paris and Nantes, from another file.
Test1 and TEst2 can be ALieoej and PAodj45p. it's arbitrary choice
I think i need a script to search one line with sqlexpress into, and change it by one data, and the second time where i find it, replace it by another data