Using select-string to find occurrences of a string

Hello Scripting Guys,

I'm unsuccessfully trying to use the select-string cmdlet to find all occurrences of the string "Number of disposed messages : " in a log directory. I can use select-string to find all occurrences of ":" in the same log folder.

Why can't the select-string cmdlet find my string?

Sincerely,

Brian Street.

p.s. I am able to use the PowerShell example # 3: PS C:\> select-string -path $pshome\en-US\*.txt -pattern "@"  I'm also able to search within the log folder for the occurrence of ":" in the log files.

August 20th, 2015 6:01pm

Thanks for the response.

I'm running the following command: select-string -Path *.txt -Pattern "Number of disposed messages :" from within the log folder.  I can search within the same folder for occurrences of ":" but as soon as I add any words inside the double-quotes, it fails to return any results.


Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 6:18pm

Thanks Mike.

ok; that definitely confirms there is something fishy with the log files I'm searching.


August 20th, 2015 6:34pm

update:

the log files were saved in Unicode format. when I saved a log file as ANSI format I was able to search the file for the occurrence of the string.

Adding -Encoding Unicode to the cmdlet resolved the issue.
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 7:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics