I have a file DJ.bat file. I am reading the content of file using powershell.
DJENGINE -l "Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_2554_20220323065246.tf.err" -sc "File=Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_2554_20220323065246.dat" -tc "Server=ABC.stg.sql.ccaintranet.com;Database=ABCTMS_FC;Table=dbo.FC_Load" "\\ccaintranet.com\dfs-dc-01\Data\Retail\Actian11\MapDesigner\fc.tf.xml"
DJENGINE -l "Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_5168_20220323074029.tf.err" -sc "File=Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_5168_20220323074029.dat" -tc "Server=ABC.stg.sql.ccaintranet.com;Database=ABCTMS_FC;Table=dbo.FC_Load" "\\ccaintranet.com\dfs-dc-01\Data\Retail\Actian11\MapDesigner\fc.tf.xml"
DJENGINE -l "Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_13272_20220323070111.tf.err" -sc "File=Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_13272_20220323070111.dat" -tc "Server=ABC.stg.sql.ccaintranet.com;Database=ABCTMS_FC;Table=dbo.FC_Load" "\\ccaintranet.com\dfs-dc-01\Data\Retail\Actian11\MapDesigner\fc.tf.xml"
I have thousand of -DJENGINE lines of statement being printed. I have just mentioned three here
I have an array $data which has thousands of data. I just mentioned two here:
TMSfuture_cost_2554_20220323065246.dat
TMSfuture_cost_5168_20220323074029.dat
I want result that the content of array are compared within the content of file being read. If the ,content of array matches then I need to delete block of code from :
" DJEngine.... to .... tf.xml"
Since these two arrays matches with file content, My expected output is:
DJENGINE -l "Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_13272_20220323070111.tf.err" -sc "File=Y:\st\Retail\FTP\2022-03-23\TMSfuture_cost_13272_20220323070111.dat" -tc "Server=ABC.stg.sql.ccaintranet.com;Database=ABCTMS_FC;Table=dbo.FC_Load" "\\ccaintranet.com\dfs-dc-01\Data\Retail\Actian11\MapDesigner\fc.tf.xml"
I tried using:
$pathOFDj='Y:\St\Retail\FTP\2022-03-23\DJ.bat'
foreach($d in $data){
foreach($line in Get-Content $pathOFDj) {
if($line -contains $d){
}
else{
$newLine+=$line
}
}
}
echo $newLine
The block which I mentioned is not being removed.