11
Mar 16

#==================================================================
#==== I needed a quick one liner to check the eventlogs for an application that stopped.
#==== Script looks at a text file with server names then scans both system and application log for the last day for messages
#==================================================================


$servers = Get-Content -Path C:\PowershellScripts\Servers.txt
ForEach ($server in $servers)
{
	Get-Eventlog -ComputerName $server -LogName system -EntryType information -After (Get-Date).AddDays(-1) | where-object { $_.Message -Like "*Stopped*" } | select MachineName, TimeWritten, message
	Get-Eventlog -ComputerName $server -LogName application -EntryType information -After (Get-Date).AddDays(-1) | where-object  { $_.Message -Like "*stopping*" } | select MachineName, Source, TimeWritten, message
}

Leave a Reply