Hi,
I am new to power shell and i am writing a code to read multiple text file and storing the first 5 lines as in different files.
I have written the log but it's not working i am doing something wrong. The script is running but generating empty output file.
Could any body help please.
$loc = "*.txt"
$pat = "^DRE Weekly"
$result = select-string -pattern $pat -path $loc
if ($result.count -gt 0) {
$outfile = foreach ($l in $result) {
$a=get-content D:\MSA_RPT\DRE_Weekly\*.txt -totalcount 5
$a[(0..2) + (4)]
}
}
$outfile | out-file -filepath "D:\test\DRE_version_details.txt"