I have a text file. Similar to this.
This is a sample data.This is a sample data.This is a sample data.SatJun0608:17:012015
WARNING:Cannot delete file.Error-101Error-100Error-102This is a sample data.This is a sample data.Error-10666This is a sample data.SatJun0610:17:012015File deleted.This is a sample data.This is a sample data.SatJun0610:17:012015File deleted.SatJun0611:17:012015
WARNING:Cannot delete file.Error-101This is a sample data.SatJun0618:17:012015
WARNING:Cannot delete file.Error-101This is a sample data.This file contain one month data. There could be multiple files like this in a directory. Script will need to check the file that modified today.
I want to get the Error-??? (Entire line of Error-) value of today's date. So far i have created this.
$cur_date1 = get-date -UFormat%c
$curdate =(get-date).ToString("ddMMyyyy")ForEach($system in(Get-Content D:\Script\system.txt)){
$dir ="\\$system\D$\Error\"
$latest = Get-ChildItem -Path $dir -Filter error*.txt | where{$_.LastWriteTime.ToString("ddMMyyyy") -eq $date }
$files=$latest.name
Foreach($file in $files){
$path= $dir+$file
$search = Get-Content $path
$a = $search| if($_ -eq $curdate){
Where-Object{$_.Contains("Error-") }
}
}
}I can check the files created today. I can get content of entire file. I can search the error- string but i am not able to search for current date.
Can anybody advise me on this?
Thanks.
If any changes need to be done in title or discription then please do so. Thanks for your time.
Update
Just to inform you my system datetime format is as follows. dd/mm/yyyy hh:mm:ss