So, you posted this on a PowerShell script assistant forum and this does not appear to be a PS question / issue but a general Windows Explorer use case question.
If you are saying you are doing this in PS, then you have to write that yourself.
Or, just use windows explorer, after setting advanced preference to search file content, then do a search and leverage preview mode, using the view menu, or pin that item to the explorer quick launch bar for easy access. This will give you a resizable split pane to the right of your file explorer list. Click a file name and it will show you the entire file contents, depending on how the file formatted.
Demo'd here:
https://www.youtube.com/watch?v=PSSDzrra21g
Update based on OP response
Alight, but what you are asking about is not something out of the box.
You have to write this yourself as I stated earlier.
Windows explorer can search virtually any file content, as long as you set it to, but it will not show you a preview without preview mode, and preview is just a tool to open the file, using the files default app.
You are asking to do a search, and land on that spot in a file based on a keyword. Again, not something out of the box on Window in any way.
So, it's a write from scratch effort. We'll help with code you've written, but not write it from scratch for you. Well, sometimes it happens, if someone is feeling really generous. However, that is what consultants are for.
Your code must find the file, keyword, open the file using the file app engine, then you have to navigate via that file object model to use the keyword to search it once opened and land on the keyword location.
This is not a off the cuff thing. It requires knowledge of each step intimately, and calling into the parent app to show it. So, it's not an off the cuff thing.
There are samples around the web on how to do this for different file types. Example:
https://social.technet.microsoft.com/wiki/contents/articles/29851.powershell-trick-search-highlight-text-in-ms-word.aspx
$objWord = New-Object -ComObject word.application
$objWord.Visible = $True
$objDoc = $objWord.Documents.Open("C:\temp\test.docx")
$FindText = "document"
foreach ($docrange in $objDoc.Words)
{
if ($docrange.Text.Trim() -eq $FindText)
{
$docrange.highlightColorIndex = [Microsoft.Office.Interop.Word.WdColorIndex]::wdYellow
}
}
Now, that is just for Word. If you have Excel, PowerPoint, Visio, PDF (this requires an addon), text (this is easiest), etc., they each have their own object model you have to know and use.