Author Posts

March 20, 2017 at 4:22 pm

Hi All

I have this , (get-content C:\Settings.xml).Replace("REAL-DB1-QA\DB1", "REAL-DB1-QA") | set-content "C:\Settings.xml" .
how can I make it ignore the case sensitive so both REAL-DB1-QA\DB1 & REaL-Db1-QA\DB1 , will be replaced ?

March 20, 2017 at 5:12 pm

(get-content C:\Settings.xml).ToUpper().Replace("REAL-DB1-QA\DB1", "REAL-DB1-QA") | set-content "C:\Settings.xml"

March 20, 2017 at 6:25 pm

Thanks Sam
worked great .

March 21, 2017 at 2:49 am

No need to uppercase all characters, '-replace' is not case-sensitive.

(get-content C:\Settings.xml) -replace 'REAL-DB1-QA\\DB1','REAL-DB1-QA' | 
set-content 'C:\Settings.xml'

March 22, 2017 at 4:07 pm

I changed it to \\ because I got errors on escape characters , but it didn't help with the case sensitive issue (only after adding .ToUpper() it was working ) . maybe I will give it another try .