How to search all folders in OneDrive for PDF containing a word?

Sunny PA Wong 1 Reputation point
2024-10-17T14:46:51.6833333+00:00

I need help with listing full pathname of PDF files containing a word.

Get-ChildItem -Path C:\Users\Me -Include *.pdf -File -Recurse -ErrorAction SilentlyContinue | Select-String -pattern “Tax” | group path | select name | Out-File -FilePath .\FindPDFcontainingTax.txt -NoClobber

output listed PDF not containing 'Tax'

Thanks in advance!

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,128 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,552 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 33,996 Reputation points
    2024-10-19T13:12:41.5433333+00:00

    Your main problem is that PDF files do not store contents in plain text. Your script should work for .TXT files.

    For PDF files you will need to use something that can "read" the PDF contents.

    https://superuser.com/questions/1278479/search-pdf-contents-with-powershell-and-output-a-file-list

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.