Powershell select-string not working as planned for an pattern array

116 views Asked by At

I am trying to search a log file for certain times which are stored in an array. I am then passing the matches back to a variable for further processing, but I am stumbling at the first hurdle. I am trying to pattern match with the following:

$times = "19/11/2014 23:56","19/11/2014 23:57","19/11/2014 23:58","19/11/2014 23:59"
Get-Content D:\tmp\App.log |  select-string -Pattern $times 

The App.log file looks like this:

19/11/14 23:59:11.470 [2752] INFO AppAdmin - Logon Request [email protected]
19/11/14 23:59:11.470 [2752] INFO AppAdmin - Logon Request for user = [email protected] succeeded. 19/11/14 23:59:12.687 [2752] INFO AppAdmin - onStreamOpened called: item = [email protected] 19/11/14 23:59:12.687 [2752] INFO AppAdmin - PrivateStreamEvents::onStreamOpened - message type 0: item = [email protected] 19/11/14 23:59:12.765 [2752] INFO AppAdmin - Logon Request [email protected]

So really the above lines should be passed to the console.

Any advice as to what could be going wrong?

Thanks!

1

There are 1 answers

0
user4003407 On BEST ANSWER
19/11/14 23:59

Is not match to

19/11/2014 23:59