How to Use Powershell to Find a Specific line and print it

Here is my case, I am building a tool for my office which can auto diagnose BSOD errors. I am using PowerShell to build this. I have isolated the file which has the location of the file I need in it. But I need to be able to search for the string "These files may be available here: " and return the next line. (I am sure this is an easy command I am missing but I am relatively new to this)

If anyone has any ideas on this I would really appreciate it.

The code I am using to find my BSOD log is this:

$bsod = Get-EventLog -LogName application -Newest 100 -Source ‘Windows Error*' | select timewritten, message | where message -match ‘bluescreen’ | ft -auto -wrap

If there is another way to harvest a BSOD stop code let me know. :slight_smile:

Environment: Windows 10 on a Dell Laptop. Has access to Admin Perms.

First of all … for me it’s a kind of very strange to automate something with a script what should happen only once or twice a year … like a BSOD. I actually haven’t seen one in the last 1.5 years.

Next …

You should not use aliasses in scripts and especially not in forums at all as it makes your code much harder to read.

And you should not use format cmdlets like Format-Table if it’s not exclusively for console output.

Take a look at …

… and pay special attention to the parameter -Context.

In general you should always read the help for the cmdlets you’re about to use completely including the examples to learn how to use them.