I have a Csv file which have huge data. I want a PowerShell script which will search for a line starting with number 19999, if found then in that line replace whatever is between IISST: and Progress with word Result.
Below is example of data.
1 ABC Test data Test data IISST: I am OK with this Progress some more data
1299 Someone needs this Test data IISST: I am OK with this Progress some more data
19999 ABC Test data Test data IISST: I want to replace this text with Result word Progress some more data
20000 ABC Test data Test data IISST: I am OK with this Progress some more data
79837 Someone needs this Test data IISST: I am OK with this Progress some more data
I have wrote below code after 3 days of struggle. and this code is removing all lines from file and adding only one line which I updated.
$search= [regex] "^19999"
$FullContentofLine= Get-Content "O:\Temp\test.csv" | select-string $search
$linenumber=$FullContentofLine.LineNumber
$linenumber
$fullContentofFile=Get-Content "O:\Temp\test.csv"
$contentUpdate = $fullContentofFile[$linenumber-1] -replace [regex] "IISST:(.*?)Progress","IISST: Result Progress"
#$contentUpdate
Set-Content "O:\Temp\test.csv" $contentUpdate