sanyam jain
sanyam jain

Reputation: 135

How can I only read the 'Applications and Services logs' using PowerShell?

How can I only read the Applications and Services logs using PowerShell? I tried Get-WinEvent, but it also includes Windows Logs.

Upvotes: 1

Views: 5985

Answers (2)

stackprotector
stackprotector

Reputation: 13451

You can filter the list of log names first and then only pass the desired log names to Get-WinEvent:

Get-WinEvent -ListLog Microsoft-Windows-* | Foreach-Object {Get-WinEvent -LogName $_.LogName -ErrorAction SilentlyContinue}

Most of the logs from Applications and Services logs are prefixed by Microsoft-Windows-. You might need to adjust this filter according to your exact needs.

Upvotes: 1

alroc
alroc

Reputation: 28174

The Get-EventLog allows you to specify a single log to retrieve via the LogName parameter.

Upvotes: 0

Related Questions